<!DOCTYPE html>
<!-- saved from url=(0077)https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work -->
<html itemscope="" itemtype="https://schema.org/QAPage" class="html__responsive "><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>How do function pointers in C work? - Stack Overflow</title>
        <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196">
        <link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a">
        <link rel="image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> 
        <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="https://stackoverflow.com/opensearch.xml">
        <link rel="canonical" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
        <meta property="og:type" content="website">
        <meta property="og:url" content="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work">
        <meta property="og:site_name" content="Stack Overflow">
        <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded">
        <meta name="twitter:card" content="summary">
        <meta name="twitter:domain" content="stackoverflow.com">
        <meta name="twitter:title" property="og:title" itemprop="name" content="How do function pointers in C work?">
        <meta name="twitter:description" property="og:description" itemprop="description" content="I had some experience lately with function pointers in C.

So going on with the tradition of answering your own questions, I decided to make a small summary of the very basics, for those who need a...">
    <script async="" src="./How do function pointers in C work_ - Stack Overflow_files/beacon.js"></script><script async="" src="./How do function pointers in C work_ - Stack Overflow_files/analytics.js"></script><script id="webpack-public-path" type="text/uri-list">https://cdn.sstatic.net/</script>
    <script src="./How do function pointers in C work_ - Stack Overflow_files/jquery.min.js"></script>
    <script async="" src="./How do function pointers in C work_ - Stack Overflow_files/stacks.min.js"></script>
    <script src="./How do function pointers in C work_ - Stack Overflow_files/stub.en.js"></script>
    
    <link rel="stylesheet" type="text/css" href="./How do function pointers in C work_ - Stack Overflow_files/stacks.css">
    <link rel="stylesheet" type="text/css" href="./How do function pointers in C work_ - Stack Overflow_files/primary.css">


    
            <link rel="alternate" type="application/atom+xml" title="Feed for question &#39;How do function pointers in C work?&#39;" href="https://stackoverflow.com/feeds/question/840501">
        <script>
            StackExchange.ready(function () {
                StackExchange.question.addAnswerIvcObservers()
            });
        </script>
            <meta name="twitter:app:country" content="US">
            <meta name="twitter:app:name:iphone" content="Stack Exchange iOS">
            <meta name="twitter:app:id:iphone" content="871299723">
            <meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work">
            <meta name="twitter:app:name:ipad" content="Stack Exchange iOS">
            <meta name="twitter:app:id:ipad" content="871299723">
            <meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work">
            <meta name="twitter:app:name:googleplay" content="Stack Exchange Android">
            <meta name="twitter:app:url:googleplay" content="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work">
            <meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">
        <script>
            StackExchange.ready(function () {

                    StackExchange.using("snippets", function () {
                        StackExchange.snippets.initSnippetRenderer();
                    });
                    
                StackExchange.using("postValidation", function () {
                    StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
                });


                StackExchange.question.init({showAnswerHelp:true,totalCommentCount:3,shownCommentCount:3,enableTables:true,questionId:840501});

                styleCode();

                    StackExchange.realtime.subscribeToQuestion('1', '840501');
                    StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.js-post-body'); });


            });
        </script>

        
        
        
        <link rel="stylesheet" type="text/css" href="./How do function pointers in C work_ - Stack Overflow_files/channels.css">
        
        
        


    <script type="application/json" data-role="module-args" data-module-name="Shared/options.mod">{"options":{"locale":"en","serverTime":1648450355,"routeName":"Questions/Show","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q\u0026A for professional and enthusiast programmers","isNoticesTabEnabled":true,"enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"cookieDomain":".stackoverflow.com","childUrl":"https://meta.stackoverflow.com","negativeVoteScoreFloor":null,"enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"6033983e61dc0ff22e445ab18cf0eead5edbbc984d1afc9c7714025cf7b14f3f","tid":"f56913b5-4524-f6f4-44db-e2bba702ec72","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true,"ab":{"hot_questions_sidebar":{"v":"signupoptincopy","g":3}}},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}},"story":{"minCompleteBodyLength":75,"likedTagsMaxLength":300,"dislikedTagsMaxLength":300},"jobPreferences":{"maxNumDeveloperRoles":2,"maxNumIndustries":4},"svgIconPath":"https://cdn.sstatic.net/Img/stacks-icons","svgIconHash":"cc5b3e0efea0"}}</script>
<script type="application/json" data-role="module-args" data-module-name="Shared/settings.mod">{"settings":{"userProfile":{"openGraphAPIKey":"4a307e43-b625-49bb-af15-ffadf2bda017"},"userMessaging":{"showNewFeatureNotice":true},"tags":{},"subscriptions":{"defaultBasicMaxTrueUpSeats":250,"defaultFreemiumMaxTrueUpSeats":50,"defaultMaxTrueUpSeats":1000},"snippets":{"renderDomain":"stacksnippets.net","snippetsEnabled":true},"site":{"allowImageUploads":true,"enableImgurHttps":true,"enableUserHovercards":true,"forceHttpsImages":true,"styleCode":true},"questions":{"enableQuestionTitleLengthLiveWarning":true,"maxTitleSize":150,"questionTitleLengthStartLiveWarningChars":50},"intercom":{"appId":"inf0secd","hostBaseUrl":"https://stacksnippets.net"},"paths":{},"monitoring":{"clientTimingsAbsoluteTimeout":30000,"clientTimingsDebounceTimeout":1000},"mentions":{"maxNumUsersInDropdown":50},"markdown":{"enableTables":true},"legal":{"oneTrustConfigId":"c3d9f1e3-55f3-4eba-b268-46cee4c6789c"},"flags":{"allowRetractingCommentFlags":true,"allowRetractingFlags":true},"elections":{"opaVoteResultsBaseUrl":"https://www.opavote.com/results/"},"comments":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true}}}</script>
<script>StackExchange.init();</script>

    <script>
        StackExchange.using.setCacheBreakers({"js/adops.en.js":"6da43f5e0a84","js/ask.en.js":"7ff9a9068fd6","js/begin-edit-event.en.js":"dd955babf04d","js/copy-transpiled.en.js":"6e17fb344f2c","js/events.en.js":"","js/explore-qlist.en.js":"2b1f34938b8b","js/full-anon.en.js":"920cc57ec2ed","js/full.en.js":"7dea62be7716","js/highlightjs-loader.en.js":"3c37abf5cb6d","js/inline-tag-editing.en.js":"c0cbc31e5702","js/keyboard-shortcuts.en.js":"7de4e127b6af","js/markdown-it-loader.en.js":"5818ef89ff9d","js/moderator.en.js":"4989aaaca9f5","js/postCollections-transpiled.en.js":"8126e59701f9","js/post-validation.en.js":"09f528ac466a","js/question-editor.en.js":"","js/review-v2-transpiled.en.js":"d4e8ed8cd584","js/revisions.en.js":"839f528889ff","js/stacks-editor.en.js":"7c971287f03c","js/tageditor.en.js":"825c9597ce2d","js/tageditornew.en.js":"857acd8b77e4","js/tagsuggestions.en.js":"1bcff7d98f97","js/unlimited-transpiled.en.js":"7ed67670b600","js/wmd.en.js":"0ccf559d0629","js/snippet-javascript-codemirror.en.js":"73fce5cc7219"});
        StackExchange.using("gps", function() {
             StackExchange.gps.init(true);
        });
    </script>
    <noscript id="noscript-css"><style>body,.top-bar{margin-top:1.9em}</style></noscript>
    <script async="" src="./How do function pointers in C work_ - Stack Overflow_files/full-anon.en.js"></script><meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A8FHS1NmdCwGqD9DwOicnHHY+y27kdWfxKa0YHSGDfv0CSpDKRHTQdQmZVPDUdaFWUsxdgVxlwAd6o+dhJykPA0AAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A8zdXi6dr1hwXEUjQrYiyYQGlU3557y5QWDnN0Lwgj9ePt66XMEvNkVWOEOWPd7TP9sBQ25X0Q15Lr1Nn4oGFQkAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A4/Htern2udN9w3yJK9QgWQxQFruxOXsXL7cW60DyCl0EZFGCSme/J33Q/WzF7bBkVvhEWDlcBiUyZaim5CpFQwAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><script src="./How do function pointers in C work_ - Stack Overflow_files/pubads_impl_2022031601.js" async=""></script><link rel="stylesheet" href="./How do function pointers in C work_ - Stack Overflow_files/clc.min.css" type="text/css"><script async="" src="./How do function pointers in C work_ - Stack Overflow_files/post-validation.en.js"></script><script async="" src="./How do function pointers in C work_ - Stack Overflow_files/highlightjs-loader.en.js"></script><link rel="preload" href="./How do function pointers in C work_ - Stack Overflow_files/f.txt" as="script"><script type="text/javascript" src="./How do function pointers in C work_ - Stack Overflow_files/f.txt"></script><link rel="preload" href="./How do function pointers in C work_ - Stack Overflow_files/f(1).txt" as="script"><script type="text/javascript" src="./How do function pointers in C work_ - Stack Overflow_files/f(1).txt"></script></head>
    <body class="question-page unified-theme">
    <div id="notify-container"></div>
    <div id="custom-header"></div>
        
<header class="top-bar js-top-bar top-bar__network">
    <div class="wmx12 mx-auto d-flex ai-center h100" role="menubar">
        <div class="-main flex--item">
                <a href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" class="left-sidebar-toggle p0 ai-center jc-center js-left-sidebar-toggle" role="menuitem" aria-haspopup="true" aria-controls="left-sidebar" aria-expanded="false"><span class="ps-relative"></span></a>
                <div class="topbar-dialog leftnav-dialog js-leftnav-dialog dno">
                    <div class="left-sidebar js-unpinned-left-sidebar" data-can-be="left-sidebar" data-is-here-when="sm"></div>
                </div>
                    <a href="https://stackoverflow.com/" class="-logo js-gps-track" data-gps-track="top_nav.click({is_current:false, location:2, destination:8})">
                        <span class="-img _glyph">Stack Overflow</span>
                    </a>



        </div>

            <ol class="list-reset d-flex gs4" role="presentation">

                    <li class="flex--item md:d-none">
                        <a href="https://stackoverflow.co/" class="-marketing-link js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:7})" data-ga="[&quot;top navigation&quot;,&quot;about menu click&quot;,null,null,null]">About</a>
                    </li>

                <li class="flex--item">
                    <a href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" class="-marketing-link js-gps-track js-products-menu" aria-controls="products-popover" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="bottom" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.products.click({location:2, destination:1})" data-ga="[&quot;top navigation&quot;,&quot;products menu click&quot;,null,null,null]">
                        Products
                    </a>
                </li>

                    <li class="flex--item md:d-none">
                        <a href="https://stackoverflow.co/teams" class="-marketing-link js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:7})" data-ga="[&quot;top navigation&quot;,&quot;learn more - teams&quot;,null,null,null]">For Teams</a>
                    </li>
            </ol>
            <div class="s-popover ws2 mtn2 p0" id="products-popover" role="menu" aria-hidden="true">
                <div class="s-popover--arrow"></div>
                <ol class="list-reset s-anchors s-anchors__inherit">
                    <li class="m6">
                        <a href="https://stackoverflow.com/questions" class="bar-sm p6 d-block h:bg-black-100 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:2})" data-ga="[&quot;top navigation&quot;,&quot;public qa submenu click&quot;,null,null,null]">
                            <span class="fs-body1 d-block">Stack Overflow</span>
                            <span class="fs-caption d-block fc-light">Public questions &amp; answers</span>
                        </a>
                    </li>
                    <li class="m6">
                        <a href="https://stackoverflow.co/teams" class="bar-sm p6 d-block h:bg-black-100 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:3})" data-ga="[&quot;top navigation&quot;,&quot;teams submenu click&quot;,null,null,null]">
                            <span class="fs-body1 d-block">Stack Overflow for Teams</span>
                            <span class="fs-caption d-block fc-light">Where developers &amp; technologists share private knowledge with coworkers</span>
                        </a>
                    </li>
                        <li class="m6">
                            <a href="https://stackoverflow.com/jobs?so_source=ProductsMenu&amp;so_medium=StackOverflow" class="bar-sm p6 d-block h:bg-black-100 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:9})" data-ga="[&quot;top navigation&quot;,&quot;jobs submenu click&quot;,null,null,null]">
                                <span class="fs-body1 d-block">Jobs</span>
                                <span class="fs-caption d-block fc-light">Programming &amp; related technical career opportunities</span>
                            </a>
                        </li>
                    <li class="m6">
                        <a href="https://stackoverflow.co/talent" class="bar-sm p6 d-block h:bg-black-100 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:5})" data-ga="[&quot;top navigation&quot;,&quot;talent submenu click&quot;,null,null,null]">
                            <span class="fs-body1 d-block">Talent</span>
                            <span class="fs-caption d-block fc-light">
Recruit tech talent &amp; build your employer brand                            </span>
                        </a>
                    </li>
                    <li class="m6">
                        <a href="https://stackoverflow.co/advertising" class="bar-sm p6 d-block h:bg-black-100 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:6})" data-ga="[&quot;top navigation&quot;,&quot;advertising submenu click&quot;,null,null,null]">
                            <span class="fs-body1 d-block">Advertising</span>
                            <span class="fs-caption d-block fc-light">Reach developers &amp; technologists worldwide</span>
                        </a>
                    </li>
                    <li class="bg-black-025 bt bc-black-075 py6 px6 bbr-md">
                        <a href="https://stackoverflow.co/" class="fc-light d-block py6 px6 h:fc-black-800 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:7})" data-ga="[&quot;top navigation&quot;,&quot;about submenu click&quot;,null,null,null]">About the company</a>
                    </li>
                </ol>
            </div>

            <form id="search" role="search" action="https://stackoverflow.com/search" class="flex--item fl-grow1 searchbar px12 js-searchbar " autocomplete="off">
                    <div class="ps-relative">
                        <input name="q" type="text" placeholder="Search…" value="" autocomplete="off" maxlength="240" class="s-input s-input__search js-search-field " aria-label="Search" aria-controls="top-search" data-controller="s-popover" data-action="focus-&gt;s-popover#show" data-s-popover-placement="bottom-start">
                        <svg aria-hidden="true" class="s-input-icon s-input-icon__search svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18l1.5-1.5ZM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z"></path></svg>
                        <div class="s-popover p0 wmx100 wmn4 sm:wmn-initial js-top-search-popover" id="top-search" role="menu">
    <div class="s-popover--arrow"></div>
    <div class="js-spinner p24 d-flex ai-center jc-center d-none">
        <div class="s-spinner s-spinner__sm fc-orange-400">
            <div class="v-visible-sr">Loading…</div>
        </div>
    </div>

    <span class="v-visible-sr js-screen-reader-info"></span>
    <div class="js-ac-results overflow-y-auto hmx3 d-none"></div>

    <div class="js-search-hints" aria-describedby="Tips for searching"></div>
</div>
                    </div>
            </form>
        
        

<ol class="overflow-x-auto ml-auto -secondary d-flex ai-center list-reset h100 user-logged-out" role="presentation">
        <li class="-item searchbar-trigger"><a href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" class="-link js-searchbar-trigger" role="button" aria-label="Search" aria-haspopup="true" aria-controls="search" title="Click to show search"><svg aria-hidden="true" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18l1.5-1.5ZM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z"></path></svg></a></li>

            <li class="-ctas">
                            <a href="https://stackoverflow.com/users/login?ssrc=head&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" class="login-link s-btn s-btn__filled py8 js-gps-track" rel="nofollow" data-gps-track="login.click" data-ga="[&quot;top navigation&quot;,&quot;login button click&quot;,null,null,null]">Log in</a>
                            <a href="https://stackoverflow.com/users/signup?ssrc=head&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" class="login-link s-btn s-btn__primary py8" rel="nofollow" data-ga="[&quot;sign up&quot;,&quot;Sign Up Navigation&quot;,&quot;Header&quot;,null,null]">Sign up</a>

            </li>

    <li class="js-topbar-dialog-corral" role="presentation">
            

    <div class="topbar-dialog siteSwitcher-dialog dno" role="menu">
        <div class="header fw-wrap">
            <h3 class="flex--item">
                <a href="https://stackoverflow.com/">current community</a>
            </h3>
            <div class="flex--item fl1">
                <div class="ai-center d-flex jc-end">
                    <button class="js-close-button s-btn s-btn__muted p0 ml8 d-none sm:d-block" type="button" aria-label="Close">
                        <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9 15 4.41Z"></path></svg>
                    </button>
                </div>
            </div>
        </div>
        <div class="modal-content bg-powder-050 current-site-container">
            <ul class="current-site ">
                    <li class="d-flex">
                            <div class="fl1">
                <a href="https://stackoverflow.com/" class="current-site-link site-link js-gps-track d-flex gs8 gsx" data-id="1" data-gps-track="site_switcher.click({ item_type:3 })">
        <div class="favicon favicon-stackoverflow site-icon flex--item" title="Stack Overflow"></div>
        <span class="flex--item fl1">
            Stack Overflow
        </span>
    </a>

    </div>
    <div class="related-links">
            <a href="https://stackoverflow.com/help" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:14 })">help</a>
            <a href="https://chat.stackoverflow.com/?tab=site&amp;host=stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a>
    </div>

                    </li>
                    <li class="related-site d-flex">
                            <div class="L-shaped-icon-container">
        <span class="L-shaped-icon"></span>
    </div>

                            <a href="https://meta.stackoverflow.com/" class=" site-link js-gps-track d-flex gs8 gsx" data-id="552" data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })">
        <div class="favicon favicon-stackoverflowmeta site-icon flex--item" title="Meta Stack Overflow"></div>
        <span class="flex--item fl1">
            Meta Stack Overflow
        </span>
    </a>

                    </li>
            </ul>
        </div>

        <div class="header" id="your-communities-header">
            <h3>
your communities            </h3>

        </div>
        <div class="modal-content" id="your-communities-section">

                <div class="call-to-login">
<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list.                </div>
        </div>

        <div class="header">
            <h3><a href="https://stackexchange.com/sites">more stack exchange communities</a>
            </h3>
            <a href="https://stackoverflow.blog/" class="float-right">company blog</a>
        </div>
        <div class="modal-content">
                <div class="child-content"></div>
        </div>        
    </div>

    </li>
</ol>

    </div>
</header>

    <script>
        StackExchange.ready(function () { StackExchange.topbar.init(); });
        StackExchange.scrollPadding.setPaddingTop(50, 10); 
    </script>



            

        
    
<div class="bg-black-025 bs-sm bt bc-black-100 ps-fixed l0 r0 b0 z-nav js-dismissable-hero" data-campaign-name="stk">
    <div class="d-flex wmx12 mx-auto px8 py12 jc-space-between ai-center lg:pl24 lg:pr24 md:fd-column sm:fd-row sm:ai-center">
        <div class="flex--item fs-body2 fl1 mr16 md:mr0 md:mb12 sm:mb0 sm:mr16">
            <p class="mb0"><strong>Join Stack Overflow</strong> to learn, share knowledge, and build your career.</p>
        </div>

        <div id="openid-buttons" class="d-flex gs8 gsx ai-center sm:jc-space-between">
            <a class="flex--item s-btn s-btn__filled ws-nowrap" href="https://stackoverflow.com/users/signup?ssrc=hero&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" rel="nofollow" data-ga="[&quot;sign up&quot;,&quot;Sign Up Navigation&quot;,&quot;Question Hero&quot;,null,null]">
                    <span class="sm:d-none">Sign up with email</span>
                    <span class="d-none sm:d-inline">Sign up</span>
                
            </a>
                <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__google ta-center js-major-provider sm:d-none" data-provider="google" data-oauthserver="https://accounts.google.com/o/oauth2/auth" data-oauthversion="2.0" data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Google&quot;,&quot;Question Hero&quot;,null,null]">
                    <svg aria-hidden="true" class="native svg-icon iconGoogle" width="18" height="18" viewBox="0 0 18 18"><path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18Z" fill="#4285F4"></path><path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17Z" fill="#34A853"></path><path d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18l2.67-2.07Z" fill="#FBBC05"></path><path d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.77 4.77 0 0 1 4.48-3.3Z" fill="#EA4335"></path></svg>
                    Sign up with Google
                </button>
                <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__github ta-center js-major-provider sm:d-none" data-provider="github" data-oauthserver="https://github.com/login/oauth/authorize" data-oauthversion="2.0" data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - GitHub&quot;,&quot;Question Hero&quot;,null,null]">
                    <svg aria-hidden="true" class="svg-icon iconGitHub" width="18" height="18" viewBox="0 0 18 18"><path d="M9 1a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38l-.01-1.49c-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.42 7.42 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48l-.01 2.2c0 .21.15.46.55.38A8.01 8.01 0 0 0 9 1Z" fill="#010101"></path></svg>
                    Sign up with GitHub
                </button>
                <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__facebook ta-center js-major-provider sm:d-none" data-provider="facebook" data-oauthserver="https://www.facebook.com/v2.0/dialog/oauth" data-oauthversion="2.0" data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Facebook&quot;,&quot;Question Hero&quot;,null,null]">
                    <svg aria-hidden="true" class="svg-icon iconFacebook" width="18" height="18" viewBox="0 0 18 18"><path d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm6.55 16v-6.2H7.46V8.4h2.09V6.61c0-2.07 1.26-3.2 3.1-3.2.88 0 1.64.07 1.87.1v2.16h-1.29c-1 0-1.19.48-1.19 1.18V8.4h2.39l-.31 2.42h-2.08V17h-2.5Z" fill="#4167B2"></path></svg>
                    Sign up with Facebook
                </button>
                <button class="flex--item s-btn s-btn__muted s-btn__icon px8 js-dismiss" title="Dismiss"><svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9 15 4.41Z"></path></svg></button>
        </div>

        <form id="login-form" action="https://stackoverflow.com/users/signup?ssrc=hero&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f840501%2fhow-do-function-pointers-in-c-work" method="POST">

            <input type="hidden" name="fkey" value="6033983e61dc0ff22e445ab18cf0eead5edbbc984d1afc9c7714025cf7b14f3f">

            <input type="hidden" name="ssrc" value="">

            <input type="hidden" id="oauth_version" name="oauth_version" value="">
            <input type="hidden" id="oauth_server" name="oauth_server" value="">

            <div id="se-login-fields">
                <input type="hidden" name="legalLinksShown" value="0">
            </div>
        </form>
        <script>
            StackExchange.ready(function () {
                StackExchange.InlineAuth.init();
            })
        </script>
    </div>
</div>

<script>
    StackExchange.ready(function () {
        StackExchange.Hero.init("stk", "a");

        var location = 0;
        if ($("body").hasClass("questions-page")) {
            location = 1;
        } else if ($("body").hasClass("question-page")) {
            location = 1;
        } else if ($("body").hasClass("faq-page")) {
            location = 5;
        } else if ($("body").hasClass("home-page")) {
            location = 3;
        }

        $('.js-cta-button').click(function () {
            StackExchange.using("gps", function () {
                StackExchange.gps.track("hero.action", { hero_action_type: 'cta', location: location }, true);
            });
        });

        // TODO: we should review the class names and whatnot in use here. Older heroes use id selectors, the newer
        // sticky question hero on SO has a .js-dismiss class instead, but it's apparently not used anywhere... 
        // It's not great. Ideally we'd have a set of classes in the partials above that would correspond to 
        // the behaviours we want here in a more clear way. 

        // sticky question-page hero at the bottom of the page on SO
        $('.js-dismiss').on('click', function () {
            StackExchange.using("gps", function () {
                StackExchange.gps.track("hero.action", { hero_action_type: "close", location: location }, true);
            });
            StackExchange.Hero.dismiss();
            $(".js-dismissable-hero").fadeOut("fast");
        });
    });
</script>



    <div class="container">
                

<div id="left-sidebar" data-is-here-when="md lg" class="left-sidebar js-pinned-left-sidebar ps-relative">
    <div class="left-sidebar--sticky-container js-sticky-leftnav">
        <nav role="navigation">
            <ol class="nav-links">
                    

<li class="ps-relative">

    <a href="https://stackoverflow.com/" class="pl8 js-gps-track nav-links--link" data-gps-track="top_nav.click({is_current:false, location:2, destination:8})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
            <div class="d-flex ai-center">
                <div class="flex--item truncate">
                    Home
                </div>
            </div>
    </a>
</li>

                <li>
                    <ol class="nav-links">
                            <li class="fs-fine tt-uppercase ml8 mt16 mb4 fc-light">Public</li>

                            

<li class="ps-relative  youarehere">

    <a id="nav-questions" href="https://stackoverflow.com/questions" class="pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current:true, location:2, destination:1})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
<svg aria-hidden="true" class="svg-icon iconGlobe" width="18" height="18" viewBox="0 0 18 18"><path d="M9 1C4.64 1 1 4.64 1 9c0 4.36 3.64 8 8 8 4.36 0 8-3.64 8-8 0-4.36-3.64-8-8-8ZM8 15.32a6.46 6.46 0 0 1-4.3-2.74 6.46 6.46 0 0 1-.93-5.01L7 11.68v.8c0 .88.12 1.32 1 1.32v1.52Zm5.72-2c-.2-.66-1-1.32-1.72-1.32h-1v-2c0-.44-.56-1-1-1H6V7h1c.44 0 1-.56 1-1V5h2c.88 0 1.4-.72 1.4-1.6v-.33a6.45 6.45 0 0 1 3.83 4.51 6.45 6.45 0 0 1-1.51 5.73v.01Z"></path></svg>            <span class="-link--channel-name">Questions</span>
    </a>
</li>



                            

<li class="ps-relative">

    <a id="nav-tags" href="https://stackoverflow.com/tags" class=" js-gps-track nav-links--link" data-gps-track="top_nav.click({is_current:false, location:2, destination:2})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
            <div class="d-flex ai-center">
                <div class="flex--item truncate">
                    Tags
                </div>
            </div>
    </a>
</li>

                            

<li class="ps-relative">

    <a id="nav-users" href="https://stackoverflow.com/users" class=" js-gps-track nav-links--link" data-gps-track="top_nav.click({is_current:false, location:2, destination:3})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
            <div class="d-flex ai-center">
                <div class="flex--item truncate">
                    Users
                </div>
            </div>
    </a>
</li>

                            <li class="d-flex ml8 mt16 mb4 jc-space-between">
                                <div class="flex--item tt-uppercase tt-uppercase fs-fine fc-light">Collectives</div>
                                <div class="flex--item fs-fine fc-light">
                                    <a href="javascript:void(0)" class="s-link s-link__inherit mr8 js-gps-track" role="button" aria-controls="popover-discover-collectives" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="top" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.click({is_current:false, location:2, destination:17})">
                                        <svg aria-hidden="true" class="svg-icon iconInfoSm" width="14" height="14" viewBox="0 0 14 14"><path d="M7 1a6 6 0 1 1 0 12A6 6 0 0 1 7 1Zm1 10V6H6v5h2Zm0-6V3H6v2h2Z"></path></svg>
                                    </a>
                                </div>
                            </li>
                                

<li class="ps-relative">

    <a id="nav-collective-discover" href="https://stackoverflow.com/collectives" class="pl8 ai-center js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current:false, location:2, destination:18})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
<svg aria-hidden="true" class="mt-auto fc-orange-400 svg-icon iconStarVerified" width="18" height="18" viewBox="0 0 18 18"><path d="M9.86.89a1.14 1.14 0 0 0-1.72 0l-.5.58c-.3.35-.79.48-1.23.33l-.72-.25a1.14 1.14 0 0 0-1.49.85l-.14.76c-.1.45-.45.8-.9.9l-.76.14c-.67.14-1.08.83-.85 1.49l.25.72c.15.44.02.92-.33 1.23l-.58.5a1.14 1.14 0 0 0 0 1.72l.58.5c.35.3.48.79.33 1.23l-.25.72c-.23.66.18 1.35.85 1.49l.76.14c.45.1.8.45.9.9l.14.76c.14.67.83 1.08 1.49.85l.72-.25c.44-.15.92-.02 1.23.33l.5.58c.46.52 1.26.52 1.72 0l.5-.58c.3-.35.79-.48 1.23-.33l.72.25c.66.23 1.35-.18 1.49-.85l.14-.76c.1-.45.45-.8.9-.9l.76-.14c.67-.14 1.08-.83.85-1.49l-.25-.72c-.15-.44-.02-.92.33-1.23l.58-.5c.52-.46.52-1.26 0-1.72l-.58-.5c-.35-.3-.48-.79-.33-1.23l.25-.72a1.14 1.14 0 0 0-.85-1.49l-.76-.14c-.45-.1-.8-.45-.9-.9l-.14-.76a1.14 1.14 0 0 0-1.49-.85l-.72.25c-.44.15-.92.02-1.23-.33l-.5-.58Zm-.49 2.67L10.6 6.6c.05.15.19.24.34.25l3.26.22c.36.03.5.48.23.71l-2.5 2.1a.4.4 0 0 0-.14.4l.8 3.16a.4.4 0 0 1-.6.44L9.2 12.13a.4.4 0 0 0-.42 0l-2.77 1.74a.4.4 0 0 1-.6-.44l.8-3.16a.4.4 0 0 0-.13-.4l-2.5-2.1a.4.4 0 0 1 .22-.7l3.26-.23a.4.4 0 0 0 .34-.25l1.22-3.03a.4.4 0 0 1 .74 0Z"></path></svg>            <span class="-link--channel-name">Explore Collectives</span>
    </a>
</li>

                            <li class="fs-fine tt-uppercase ml8 mt16 mb4 fc-light">Find a Job</li>
                            

<li class="ps-relative">

    <a id="nav-jobs" href="https://stackoverflow.com/jobs?so_medium=StackOverflow&amp;so_source=SiteNav" class=" js-gps-track nav-links--link" data-gps-track="top_nav.click({is_current:false, location:2, destination:6})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
            <div class="d-flex ai-center">
                <div class="flex--item truncate">
                    Jobs
                </div>
            </div>
    </a>
</li>

                            

<li class="ps-relative">

    <a id="nav-companies" href="https://stackoverflow.com/jobs/companies?so_medium=StackOverflow&amp;so_source=SiteNav" class=" js-gps-track nav-links--link" data-gps-track="top_nav.click({is_current:false, location:2, destination:12})" aria-controls="" data-controller="" data-s-popover-placement="right" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never">
            <div class="d-flex ai-center">
                <div class="flex--item truncate">
                    Companies
                </div>
            </div>
    </a>
</li>

                    </ol>
                </li>
                   


<li>
    <ol class="nav-links">
                

<div class="js-freemium-cta ps-relative">

    <div class="fs-fine tt-uppercase ml8 mt16 mb8 fc-light">Teams</div>

    <div class="bt bl bb bc-black-075 p12 pb6 fc-black-600 blr-sm overflow-hidden">
        <strong class="fc-black-750 mb6">Stack Overflow for Teams</strong>
        – Collaborate and share knowledge with a private group.
        
        <img class="wmx100 mx-auto my8 h-auto d-block" width="139" height="114" src="./How do function pointers in C work_ - Stack Overflow_files/teams-illo-free-sidebar-promo.svg" alt="">

        <a href="https://stackoverflow.com/teams/create/free?utm_source=so-owned&amp;utm_medium=side-bar&amp;utm_campaign=campaign-38&amp;utm_content=cta" class="w100 s-btn s-btn__primary s-btn__xs js-gps-track" data-gps-track="teams.create.left-sidenav.click({ Action: 6 })" data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav free cta&quot;,&quot;stackoverflow.com/teams/create/free&quot;,null,null]">Create a free Team</a>
        <a href="https://stackoverflow.co/teams" class="w100 s-btn s-btn__muted s-btn__xs js-gps-track" data-gps-track="teams.create.left-sidenav.click({ Action: 5 })" data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav free cta&quot;,&quot;stackoverflow.com/teams&quot;,null,null]">What is Teams?</a>
    </div>
</div>

            <li class="d-flex ai-center jc-space-between ml8 mt24 mb4 js-create-team-cta d-none">
                <div class="flex--item tt-uppercase fs-fine fc-light">Teams</div>
                <div class="flex--item">
                    <a href="javascript:void(0)" class="s-link p12 fc-black-500 h:fc-black-800 js-gps-track" role="button" aria-controls="popover-teams-create-cta" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="bottom-start" data-s-popover-toggle-class="is-selected" data-gps-track="teams.create.left-sidenav.click({ Action: ShowInfo })" data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav show teams info&quot;,null,null,null]">
                        <svg aria-hidden="true" class="svg-icon iconInfoSm" width="14" height="14" viewBox="0 0 14 14"><path d="M7 1a6 6 0 1 1 0 12A6 6 0 0 1 7 1Zm1 10V6H6v5h2Zm0-6V3H6v2h2Z"></path></svg>
                    </a>

                </div>
            </li>
            <li class="ps-relative js-create-team-cta d-none">
                <a href="https://stackoverflow.com/teams/create/free?utm_source=so-owned&amp;utm_medium=side-bar&amp;utm_campaign=campaign-38&amp;utm_content=cta" class="pl8 js-gps-track nav-links--link" title="Stack Overflow for Teams is a private, secure spot for your organization&#39;s questions and answers." data-gps-track="teams.create.left-sidenav.click({ Action: FreemiumTeamsCreateClick })" data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav team click&quot;,&quot;stackoverflow.com/teams/create/free&quot;,null,null]">
                    <div class="d-flex ai-center">
                        <div class="flex--item s-avatar va-middle bg-orange-400">
                            <div class="s-avatar--letter mtn1">
                                <svg aria-hidden="true" class="svg-icon iconBriefcaseSm" width="14" height="14" viewBox="0 0 14 14"><path d="M4 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1h.5c.83 0 1.5.67 1.5 1.5v5c0 .83-.67 1.5-1.5 1.5h-7A1.5 1.5 0 0 1 2 10.5v-5C2 4.67 2.67 4 3.5 4H4V3Zm5 1V3H5v1h4Z"></path></svg>
                            </div>
                            <svg aria-hidden="true" class="native s-avatar--badge svg-icon iconShieldXSm" width="9" height="10" viewBox="0 0 9 10"><path d="M0 1.84 4.5 0 9 1.84v3.17C9 7.53 6.3 10 4.5 10 2.7 10 0 7.53 0 5.01V1.84Z" fill="var(--white)"></path><path d="M1 2.5 4.5 1 8 2.5v2.51C8 7.34 5.34 9 4.5 9 3.65 9 1 7.34 1 5.01V2.5Zm2.98 3.02L3.2 7h2.6l-.78-1.48a.4.4 0 0 1 .15-.38c.34-.24.73-.7.73-1.14 0-.71-.5-1.23-1.41-1.23-.92 0-1.39.52-1.39 1.23 0 .44.4.9.73 1.14.12.08.18.23.15.38Z" fill="var(--black-500)"></path></svg>
                        </div>
                        <div class="flex--item pl6">
                            Create free Team
                        </div>
                    </div>
                </a>
            </li>
    </ol>
</li> 
            </ol>
        </nav>
    </div>

        <div class="s-popover ws2" id="popover-discover-collectives" role="menu" aria-hidden="true">
            <div class="s-popover--arrow"></div>
            <div>
                <svg aria-hidden="true" class="fc-orange-500 float-right ml24 svg-spot spotCollective" width="48" height="48" viewBox="0 0 48 48"><path d="M25.5 7a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM14 18.25c0-.69.56-1.25 1.25-1.25h22.5c.69 0 1.25.56 1.25 1.25V37.5a1 1 0 0 1-1.6.8l-4.07-3.05a1.25 1.25 0 0 0-.75-.25H15.25c-.69 0-1.25-.56-1.25-1.25v-15.5ZM7 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0ZM25.5 48a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM48 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Z" opacity=".2"></path><path d="M21 3.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0ZM24.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM0 23.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0ZM3.5 22a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM21 44.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Zm3.5-1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm20-23a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7ZM43 23.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm-23.23-3.14a1 1 0 0 1-.13 1.4l-2.08 1.74 2.08 1.73a1 1 0 1 1-1.28 1.54l-2.42-2.02a1.63 1.63 0 0 1 0-2.5l2.42-2.02a1 1 0 0 1 1.4.13Zm7.59 1.41a1 1 0 1 1 1.28-1.54l2.42 2.02c.78.65.78 1.85 0 2.5l-2.42 2.02a1 1 0 1 1-1.28-1.54l2.08-1.73-2.08-1.73ZM24.12 18a1 1 0 0 1 .87 1.12l-1 8a1 1 0 1 1-1.98-.24l1-8a1 1 0 0 1 1.11-.87Zm-11.87-5C11.01 13 10 14 10 15.25v15.5c0 1.24 1 2.25 2.25 2.25h17.33c.06 0 .11.02.15.05l4.07 3.05a2 2 0 0 0 3.2-1.6V15.25c0-1.24-1-2.25-2.25-2.25h-22.5ZM12 15.25c0-.14.11-.25.25-.25h22.5c.14 0 .25.11.25.25V34.5l-4.07-3.05a2.2 2.2 0 0 0-1.35-.45H12.25a.25.25 0 0 1-.25-.25v-15.5Zm7.24-10.68a1 1 0 1 0-.48-1.94A22.04 22.04 0 0 0 2.91 17.7a1 1 0 1 0 1.92.58 20.04 20.04 0 0 1 14.4-13.72Zm11.05-1.66a1 1 0 0 0-.58 1.92c6.45 1.92 11.54 7 13.46 13.46a1 1 0 1 0 1.92-.58 22.05 22.05 0 0 0-14.8-14.8ZM4.57 28.76a1 1 0 0 0-1.94.48 22.03 22.03 0 0 0 16.13 16.13 1 1 0 1 0 .48-1.94A20.03 20.03 0 0 1 4.57 28.76Zm40.8.48a1 1 0 1 0-1.94-.48 20.04 20.04 0 0 1-13.72 14.41 1 1 0 0 0 .58 1.92 22.04 22.04 0 0 0 15.08-15.85Z"></path></svg>
                <div class="pt4 fw-bold">Collectives on Stack Overflow</div>
                <p class="my16 fs-caption fc-medium">Find centralized, trusted content and collaborate around the technologies you use most.</p>
                <a href="https://stackoverflow.com/collectives" class="js-gps-track s-btn s-btn__primary s-btn__xs" data-gps-track="top_nav.click({is_current:false, location:2, destination:18})">
                    Learn more
                </a>
            </div>
        </div>


        <div class="s-popover" id="popover-teams-create-cta" role="menu" aria-hidden="true">
            <div class="s-popover--arrow"></div>

            <div class="ps-relative overflow-hidden">
                <p class="mb2"><strong>Teams</strong></p>
                <p class="mb12 fs-caption fc-black-400">Q&amp;A for work</p>
                <p class="mb12 fs-caption fc-medium">Connect and share knowledge within a single location that is structured and easy to search.</p>
                <a href="https://stackoverflow.co/teams" class="js-gps-track s-btn s-btn__primary s-btn__xs" data-gps-track="teams.create.left-sidenav.click({ Action: CtaClick })" data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav cta&quot;,&quot;stackoverflow.com/teams&quot;,null,null]">
                    Learn more
                </a>
            </div>

            <div class="ps-absolute t8 r8">
                <svg aria-hidden="true" class="fc-orange-500 svg-spot spotPeople" width="48" height="48" viewBox="0 0 48 48"><path d="M13.5 28a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9ZM7 30a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v5h11v-5a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v10a2 2 0 0 1-2 2H33v5a1 1 0 0 1-1 1H20a1 1 0 0 1-1-1v-5H8a1 1 0 0 1-1-1V30Zm25-6.5a4.5 4.5 0 1 0 9 0 4.5 4.5 0 0 0-9 0ZM24.5 34a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z" opacity=".2"></path><path d="M16.4 26.08A6 6 0 1 0 7.53 26C5.64 26.06 4 27.52 4 29.45V40a1 1 0 0 0 1 1h9a1 1 0 1 0 0-2h-4v-7a1 1 0 1 0-2 0v7H6v-9.55c0-.73.67-1.45 1.64-1.45H16a1 1 0 0 0 .4-1.92ZM12 18a4 4 0 1 1 0 8 4 4 0 0 1 0-8Zm16.47 14a6 6 0 1 0-8.94 0A3.6 3.6 0 0 0 16 35.5V46a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V35.5c0-1.94-1.64-3.42-3.53-3.5ZM20 28a4 4 0 1 1 8 0 4 4 0 0 1-8 0Zm-.3 6h8.6c1 0 1.7.75 1.7 1.5V45h-2v-7a1 1 0 1 0-2 0v7h-4v-7a1 1 0 1 0-2 0v7h-2v-9.5c0-.75.7-1.5 1.7-1.5ZM42 22c0 1.54-.58 2.94-1.53 4A3.5 3.5 0 0 1 44 29.45V40a1 1 0 0 1-1 1h-9a1 1 0 1 1 0-2h4v-7a1 1 0 1 1 2 0v7h2v-9.55A1.5 1.5 0 0 0 40.48 28H32a1 1 0 0 1-.4-1.92A6 6 0 1 1 42 22Zm-2 0a4 4 0 1 0-8 0 4 4 0 0 0 8 0Z"></path><g opacity=".35"><path d="M17 10a1 1 0 011-1h12a1 1 0 110 2H18a1 1 0 01-1-1Zm1-5a1 1 0 100 2h12a1 1 0 100-2H18ZM14 1a1 1 0 00-1 1v12a1 1 0 001 1h5.09l4.2 4.2a1 1 0 001.46-.04l3.7-4.16H34a1 1 0 001-1V2a1 1 0 00-1-1H14Zm1 12V3h18v10h-5a1 1 0 00-.75.34l-3.3 3.7-3.74-3.75a1 1 0 00-.71-.29H15Z"></path></g></svg>
            </div>
        </div>


</div>




        <div id="content" class="snippet-hidden">

            
<div itemprop="mainEntity" itemscope="" itemtype="https://schema.org/Question">
    <link itemprop="image" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a">

    <div class="inner-content clearfix">

        

            <div id="question-header" class="d-flex sm:fd-column">
                        <h1 itemprop="name" class="fs-headline1 ow-break-word mb8 flex--item fl1"><a href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work" class="question-hyperlink">How do function pointers in C work?</a></h1>
                <div class="ml12 aside-cta flex--item print:d-none sm:ml0 sm:mb12 sm:order-first sm:as-end">
                        <a href="https://stackoverflow.com/questions/ask" class="ws-nowrap s-btn s-btn__primary">
        Ask Question
    </a>

                </div>
            </div>
            <div class="d-flex fw-wrap pb8 mb16 bb bc-black-075">
                    <div class="flex--item ws-nowrap mr16 mb8" title="2009-05-08 15:49:17Z">
                        <span class="fc-light mr2">Asked</span>
                        <time itemprop="dateCreated" datetime="2009-05-08T15:49:17">12 years, 10 months ago</time>
                    </div>
                    <div class="flex--item ws-nowrap mr16 mb8">
                        <span class="fc-light mr2">Modified</span>
                        <a href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work?lastactivity" class="s-link s-link__inherit" title="2021-01-08 09:19:48Z">1 year, 2 months ago</a>
                    </div>
                    <div class="flex--item ws-nowrap mb8" title="Viewed 906,290 times">
                        <span class="fc-light mr2">Viewed</span>
                        906k times
                    </div>
            </div>
            <div id="mainbar" role="main" aria-label="question and answers">

                
<div class="question" data-questionid="840501" data-position-on-page="0" data-score="1404" id="question">
    <style>
    </style>
<div class="js-zone-container zone-container-main">
    <div id="dfp-tlb" class="everyonelovesstackoverflow everyoneloves__top-leaderboard everyoneloves__leaderboard" data-dfp-zone="true" style="min-height: auto; height: auto; display: none;" data-google-query-id="CKaAj62_6PYCFQrvmgodWQwC0Q" data-clc-ready="true"><div id="google_ads_iframe_/248424177/stackoverflow.com/lb/question-pages_0__container__" style="border: 0pt none; width: 728px; height: auto; min-height: auto; display: none;"></div></div>
    <div class="js-report-ad-button-container " style="width: 728px"></div>
</div>

    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="840501">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-rsucd54c">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-rsucd54c" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This question shows research effort; it is useful and clear<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="1404">
            1404
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-f92w097b">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-f92w097b" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This question does not show any research effort; it is unclear or not useful<div class="s-popover--arrow"></div></div>

        <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4 js-gps-track" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Bookmark (1059)" data-selected-classes="fc-yellow-600" data-gps-track="post.click({ item: 1, priv: 0, post_type: 1 })" aria-describedby="--stacks-s-tooltip-rlhcab32">
            <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 0 0-2 2v14l5-4 5 4V3a2 2 0 0 0-2-2H6Zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77Z"></path></svg>
            <div class="js-bookmark-count mt4" data-value="1059">1059</div>
        </button><div id="--stacks-s-tooltip-rlhcab32" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Bookmark this question.<div class="s-popover--arrow"></div></div>
    

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/840501/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-9b8ttjjr"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-9b8ttjjr" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="postcell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
                
<p>I had some experience lately with function pointers in C.</p>

<p>So going on with the tradition of answering your own questions, I decided to make a small summary of the very basics, for those who need a quick dive-in to the subject.</p>
    </div>

        <div class="mt24 mb12">
            <div class="post-taglist d-flex gs4 gsy fd-column">
                <div class="d-flex ps-relative fw-wrap">
                    <a href="https://stackoverflow.com/questions/tagged/c" class="post-tag js-gps-track" title="show questions tagged &#39;c&#39;" rel="tag">c</a> <a href="https://stackoverflow.com/questions/tagged/function-pointers" class="post-tag js-gps-track" title="show questions tagged &#39;function-pointers&#39;" rel="tag">function-pointers</a> 
                </div>
            </div>
        </div>

    <div class="mb0 ">
        <div class="mt16 d-flex gs8 gsy fw-wrap jc-end ai-start pt4 mb16">
            <div class="flex--item mr16 fl1 w96">
                


<div class="js-post-menu pt2" data-post-id="840501">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/q/840501" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this question" data-gps-track="post.click({ item: 2, priv: 0, post_type: 1 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this question" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="question" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="1" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-0" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-0"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this question</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/2.5/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 2.5">CC BY-SA 2.5</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/840501/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 1 })" title="">Improve this question</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-840501" class="s-btn s-btn__link js-follow-post js-follow-question js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 1 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-tz6nqnfw">
                    Follow
                </button><div id="--stacks-s-tooltip-tz6nqnfw" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this question to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>

                <div class="post-signature flex--item">
<div class="user-info ">
    <div class="user-action-time">
        asked <span title="2009-05-08 15:49:17Z" class="relativetime">May 8, 2009 at 15:49</span>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
                </div>
            <div class="post-signature flex--item">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of May 8, 2009 at 15:56. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-840501" href="https://stackoverflow.com/posts/840501/revisions" title="show revision history for this post">
        Yuval Adam
        </a>
    </div>
</div>

            </div>
        </div>
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">3</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-840501" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="840501" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-24019553" class="comment js-comment " data-comment-id="24019553" data-comment-owner-id="541412" data-comment-score="40">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="supernova">40</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Also: For a bit of an in-depth analysis of C pointers, see <a href="https://blogs.oracle.com/ksplice/entry/the_ksplice_pointer_challenge" rel="nofollow noreferrer">blogs.oracle.com/ksplice/entry/the_ksplice_pointer_challenge</a>. Also, <a href="http://savannah.nongnu.org/projects/pgubook/" rel="nofollow noreferrer">Programming from the Ground Up</a> shows how they work on the machine level. Understanding <a href="http://stackoverflow.com/a/897414/541412">C's "memory model"</a> is very useful for understanding how C pointers work.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/541412/abbafei" title="2,988 reputation" class="comment-user">Abbafei</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment24019553_840501"><span title="2013-05-22 11:17:14Z, License: CC BY-SA 3.0" class="relativetime-clean">May 22, 2013 at 11:17</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-39892991" class="comment js-comment " data-comment-id="39892991" data-comment-owner-id="1646170" data-comment-score="9">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">9</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Great info. By the title though, I would have expected to really see an explanation of how "function pointers work", not how they are coded :)</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/1646170/bogdan-alexandru" title="5,244 reputation" class="comment-user">Bogdan Alexandru</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment39892991_840501"><span title="2014-08-28 12:39:46Z, License: CC BY-SA 3.0" class="relativetime-clean">Aug 28, 2014 at 12:39</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-116049531" class="comment js-comment " data-comment-id="116049531" data-comment-owner-id="-1" data-comment-score="1">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="cool">1</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">The following answer is shorter and a lot much easier to understand: <a href="https://stackoverflow.com/a/142809/2188550">stackoverflow.com/a/142809/2188550</a></span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<span class="comment-user">user2188550</span>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment116049531_840501"><span title="2021-01-08 22:31:35Z, License: CC BY-SA 4.0" class="relativetime-clean">Jan 8, 2021 at 22:31</span></a></span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-840501" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>

</div>


<div class="js-zone-container zone-container-responsive">
    <div id="dfp-isb" class="everyonelovesstackoverflow everyoneloves__inline-sidebar mx-auto" style="min-height: auto; height: auto; display: none;"></div>
    <div class="js-report-ad-button-container mx-auto" style="width: 300px"></div>
</div>

                <div id="answers">
                    <a name="tab-top"></a>
                    <div id="answers-header">
                        <div class="answers-subheader d-flex ai-center mb8">
                            <div class="flex--item fl1">
                                <h2 class="mb0" data-answercount="11">
                                        11 Answers
                                    <span style="display:none;" itemprop="answerCount">11</span>
                                </h2>
                            </div>
                            <div class="flex--item">
                                

<div class="d-flex g4 gsx ai-center sm:fd-column sm:ai-start">
    <div class="d-flex fd-column ai-end sm:ai-start">
        <label class="flex--item fs-caption" for="answer-sort-dropdown-select-menu">
            Sorted by:
        </label>
        <a class="js-sort-preference-change s-link flex--item fs-fine d-none" data-value="ScoreDesc" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work?answertab=scoredesc#tab-top">
            Reset to default
        </a>
    </div>
    <div class="flex--item s-select">
        <select id="answer-sort-dropdown-select-menu">
                    <option value="scoredesc" selected="selected">
                        Highest score (default)
                    </option>
                    <option value="modifieddesc">
                        Date modified (newest first)
                    </option>
                    <option value="createdasc">
                        Date created (oldest first)
                    </option>
        </select>
    </div>
</div>

          
                            </div>
                        </div>
                            

<div class="js-mfnes-container s-notice s-notice__info">
    <div class="d-flex jc-space-between ai-center">
        <div class="flex--item">
            <p class="js-mfnes-link fs-body2 m0">
                Не нашли ответ? <a href="https://ru.stackoverflow.com/questions/ask?utm=soenseru&amp;fromen=00cd335040767">Задайте вопрос на Stack Overflow на русском.</a>
            </p>
        </div>
        <div class="flex--item">
            <button class="js-mfnes-dismiss s-btn p0" type="button" aria-label="Dismiss"><svg aria-hidden="true" class="svg-icon iconClearSm" width="14" height="14" viewBox="0 0 14 14"><path d="M12 3.41 10.59 2 7 5.59 3.41 2 2 3.41 5.59 7 2 10.59 3.41 12 7 8.41 10.59 12 12 10.59 8.41 7 12 3.41Z"></path></svg></button>
        </div>
    </div>
</div>

<script>
    $(document)
        .ready(function () {
            var notification = $('.js-mfnes-container');
            notification.find('.js-mfnes-dismiss').on('click',
                function () {
                    notification.remove();
                    $.ajax("/mfnes/dismiss/840501/ru/4");
                });
            notification.find('.js-mfnes-link a').on('click',
                function () {
                    $.ajax("/mfnes/click/840501/ru/4");
                });
        });
</script>                    </div>


                                          
<a name="840504"></a>
<div id="answer-840504" class="answer js-answer accepted-answer" data-answerid="840504" data-score="1634" data-position-on-page="1" data-highest-scored="1" data-question-has-accepted-highest-score="1" data-ivc="/answers/840504/ivc/9f35?sort=4&amp;shared=0&amp;position=1&amp;accepted=1&amp;highest=1" itemprop="acceptedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="840504">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-h6m0864o">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-h6m0864o" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="1634">
            1634
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-h1qmvz9d">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-h1qmvz9d" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/840504/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-wrjhjx6o"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-wrjhjx6o" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<h1>Function pointers in C</h1>

<p>Let's start with a basic function which we will be <em>pointing to</em>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">addInt</span><span class="hljs-params">(<span class="hljs-type">int</span> n, <span class="hljs-type">int</span> m)</span> {
    <span class="hljs-keyword">return</span> n+m;
}
</code></pre>

<p>First thing, let's define a pointer to a function which receives 2 <code>int</code>s and returns an <code>int</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> (*functionPtr)(<span class="hljs-type">int</span>,<span class="hljs-type">int</span>);
</code></pre>

<p>Now we can safely point to our function:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">functionPtr = &amp;addInt;
</code></pre>

<p>Now that we have a pointer to the function, let's use it:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> sum = (*functionPtr)(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>); <span class="hljs-comment">// sum == 5</span>
</code></pre>

<p>Passing the pointer to another function is basically the same:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">add2to3</span><span class="hljs-params">(<span class="hljs-type">int</span> (*functionPtr)(<span class="hljs-type">int</span>, <span class="hljs-type">int</span>))</span> {
    <span class="hljs-keyword">return</span> (*functionPtr)(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>);
}
</code></pre>

<p>We can use function pointers in return values as well (try to keep up, it gets messy):</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-comment">// this is a function called functionFactory which receives parameter n</span>
<span class="hljs-comment">// and returns a pointer to another function which receives two ints</span>
<span class="hljs-comment">// and it returns another int</span>
<span class="hljs-type">int</span> (*functionFactory(<span class="hljs-type">int</span> n))(<span class="hljs-type">int</span>, <span class="hljs-type">int</span>) {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Got parameter %d"</span>, n);
    <span class="hljs-type">int</span> (*functionPtr)(<span class="hljs-type">int</span>,<span class="hljs-type">int</span>) = &amp;addInt;
    <span class="hljs-keyword">return</span> functionPtr;
}
</code></pre>

<p>But it's much nicer to use a <code>typedef</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-title function_">int</span> <span class="hljs-params">(*myFuncDef)</span><span class="hljs-params">(<span class="hljs-type">int</span>, <span class="hljs-type">int</span>)</span>;
<span class="hljs-comment">// note that the typedef name is indeed myFuncDef</span>

myFuncDef <span class="hljs-title function_">functionFactory</span><span class="hljs-params">(<span class="hljs-type">int</span> n)</span> {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Got parameter %d"</span>, n);
    myFuncDef functionPtr = &amp;addInt;
    <span class="hljs-keyword">return</span> functionPtr;
}
</code></pre>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2009-05-08T15:49:59"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="840504">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/840504" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-1" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-1"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 3.0">CC BY-SA 3.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/840504/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-840504" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-r9moxtoo">
                    Follow
                </button><div id="--stacks-s-tooltip-r9moxtoo" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info user-hover">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/840504/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2016-12-29 22:23:52Z" class="relativetime">Dec 29, 2016 at 22:23</span></a>
    </div>
    <div class="user-gravatar32">
        <a href="https://stackoverflow.com/users/675568/tom-zych"><div class="gravatar-wrapper-32"><img src="./How do function pointers in C work_ - Stack Overflow_files/c1cfe53579fb7b2afd58949be94cf97e.png" alt="user avatar" width="32" height="32" class="bar-sm"></div></a>
    </div>
    <div class="user-details">
        <a href="https://stackoverflow.com/users/675568/tom-zych">Tom Zych</a>
        <div class="-flair">
            <span class="reputation-score" title="reputation score 12,779" dir="ltr">12.8k</span><span title="9 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">9</span></span><span class="v-visible-sr">9 gold badges</span><span title="35 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">35</span></span><span class="v-visible-sr">35 silver badges</span><span title="51 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">51</span></span><span class="v-visible-sr">51 bronze badges</span>
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2009-05-08 15:49:59Z" class="relativetime">May 8, 2009 at 15:49</span>
    </div>
    <div class="user-gravatar32">
        <a href="https://stackoverflow.com/users/24545/yuval-adam"><div class="gravatar-wrapper-32"><img src="./How do function pointers in C work_ - Stack Overflow_files/omB1R.jpg" alt="user avatar" width="32" height="32" class="bar-sm"></div></a>
    </div>
    <div class="user-details" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
        <a href="https://stackoverflow.com/users/24545/yuval-adam">Yuval Adam</a><span class="d-none" itemprop="name">Yuval Adam</span>
        <div class="-flair">
            <span class="reputation-score" title="reputation score 154,898" dir="ltr">155k</span><span title="89 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">89</span></span><span class="v-visible-sr">89 gold badges</span><span title="297 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">297</span></span><span class="v-visible-sr">297 silver badges</span><span title="388 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">388</span></span><span class="v-visible-sr">388 bronze badges</span>
        </div>
    </div>
</div>


            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">11</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-840504" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="840504" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="6" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-648758" class="comment js-comment " data-comment-id="648758" data-comment-owner-id="62706" data-comment-score="23">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">23</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Thanks for the great info. Could you add some insight on where function pointers are used or happen to be particularly useful?</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/62706/rich-carpenter" title="1,058 reputation" class="comment-user">Rich.Carpenter</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment648758_840504"><span title="2009-05-08 15:55:02Z, License: CC BY-SA 2.5" class="relativetime-clean">May 8, 2009 at 15:55</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-651729" class="comment js-comment " data-comment-id="651729" data-comment-owner-id="23118" data-comment-score="360">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="supernova">360</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">"functionPtr = &amp;addInt;" can also be written (and often is) as " functionPtr = addInt;" which is also valid since the standard says that a function name in this context is converted to the address of the function.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/23118/hlovdal" title="24,320 reputation" class="comment-user">hlovdal</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment651729_840504"><span title="2009-05-09 14:39:44Z, License: CC BY-SA 2.5" class="relativetime-clean">May 9, 2009 at 14:39</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-654142" class="comment js-comment " data-comment-id="654142" data-comment-owner-id="34509" data-comment-score="25">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">25</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">hlovdal, in this context it's interesting to explain that this is what enables one to write functionPtr = ******************addInt;</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/34509/johannes-schaub-litb" title="479,105 reputation" class="comment-user">Johannes Schaub - litb</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment654142_840504"><span title="2009-05-10 17:54:30Z, License: CC BY-SA 2.5" class="relativetime-clean">May 10, 2009 at 17:54</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-28653610" class="comment js-comment " data-comment-id="28653610" data-comment-owner-id="2561421" data-comment-score="116">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="supernova">116</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">@Rich.Carpenter I know this is 4 years too late, but I figure other people might benefit from this: <b>Function pointers are useful for passing functions as parameters to other functions</b>. It took a lot of searching for me to find that answer for some odd reason. So basically, it gives C pseudo first-class functionality.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/2561421/giant91" title="1,133 reputation" class="comment-user">giant91</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment28653610_840504"><span title="2013-10-13 02:28:01Z, License: CC BY-SA 3.0" class="relativetime-clean">Oct 13, 2013 at 2:28</span></a></span>
                        <span title="this comment was edited 1 time">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>
    <li id="comment-52462409" class="comment js-comment " data-comment-id="52462409" data-comment-owner-id="224132" data-comment-score="27">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">27</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">@Rich.Carpenter: function pointers are nice for runtime CPU detection.  Have multiple versions of some functions to take advantage of SSE, popcnt, AVX, etc.  At startup, set your function pointers to the best version of each function for the current CPU.  In your other code, just call through the function pointer instead of having conditional branches on the CPU features everywhere.  Then you can do complicated logic about deciding that well, even though this CPU supports <code>pshufb</code>, it's slow, so the earlier implementation is still faster.  x264/x265 use this extensively, and are open source.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/224132/peter-cordes" title="278,326 reputation" class="comment-user">Peter Cordes</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment52462409_840504"><span title="2015-08-30 02:22:31Z, License: CC BY-SA 3.0" class="relativetime-clean">Aug 30, 2015 at 2:22</span></a></span>
                        <span title="this comment was edited 2 times">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-840504" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button"></a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link " title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button">Show <b>6</b> more comments</a>
        </div>         
    </div>
    </div>
</div>
<div class="js-zone-container zone-container-main">
    <div id="dfp-mlb" class="everyonelovesstackoverflow everyoneloves__mid-leaderboard everyoneloves__leaderboard" data-clc-prefilled="true" style="min-height: auto; height: auto; display: none;" data-google-query-id="CMWIj62_6PYCFYiMmwodikoC4w" data-clc-ready="true"><div id="google_ads_iframe_/248424177/stackoverflow.com/mlb/question-pages_0__container__" style="border: 0pt none; width: 728px; height: auto; min-height: auto; display: none;"></div></div>
    <div class="js-report-ad-button-container " style="width: 728px"></div>
</div>
                                          
<a name="840703"></a>
<div id="answer-840703" class="answer js-answer" data-answerid="840703" data-score="326" data-position-on-page="2" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/840703/ivc/9f35?sort=4&amp;shared=0&amp;position=2&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="840703">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-dlbfi8zd">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-dlbfi8zd" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="326">
            326
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-2vwhti0b">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-2vwhti0b" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/840703/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-b8lpnzx6"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-b8lpnzx6" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p><strong>Function pointers in C can be used to perform object-oriented programming in C.</strong></p>

<p>For example, the following lines is written in C:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">String s1 = newString();
s1-&gt;<span class="hljs-built_in">set</span>(s1, <span class="hljs-string">"hello"</span>);
</code></pre>

<p>Yes, the <code>-&gt;</code> and the lack of a <code>new</code> operator is a dead give away, but it sure seems to imply that we're setting the text of some <code>String</code> class to be <code>"hello"</code>.</p>

<p>By using function pointers, <strong>it is possible to emulate methods in C</strong>.</p>

<p>How is this accomplished?</p>

<p>The <code>String</code> class is actually a <code>struct</code> with a bunch of function pointers which act as a way to simulate methods. The following is a partial declaration of the <code>String</code> class:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">String_Struct</span>* <span class="hljs-title">String</span>;</span>

<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">String_Struct</span>
{</span>
    <span class="hljs-type">char</span>* (*get)(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self);
    <span class="hljs-type">void</span> (*<span class="hljs-built_in">set</span>)(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self, <span class="hljs-type">char</span>* value);
    <span class="hljs-type">int</span> (*length)(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self);
};

<span class="hljs-type">char</span>* <span class="hljs-title function_">getString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self)</span>;
<span class="hljs-type">void</span> <span class="hljs-title function_">setString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self, <span class="hljs-type">char</span>* value)</span>;
<span class="hljs-type">int</span> <span class="hljs-title function_">lengthString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self)</span>;

String <span class="hljs-title function_">newString</span><span class="hljs-params">()</span>;
</code></pre>

<p>As can be seen, the methods of the <code>String</code> class are actually function pointers to the declared function. In preparing the instance of the <code>String</code>, the <code>newString</code> function is called in order to set up the function pointers to their respective functions:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">String <span class="hljs-title function_">newString</span><span class="hljs-params">()</span>
{
    String self = (String)<span class="hljs-built_in">malloc</span>(<span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">struct</span> String_Struct));

    self-&gt;get = &amp;getString;
    self-&gt;<span class="hljs-built_in">set</span> = &amp;setString;
    self-&gt;length = &amp;lengthString;

    self-&gt;<span class="hljs-built_in">set</span>(self, <span class="hljs-string">""</span>);

    <span class="hljs-keyword">return</span> self;
}
</code></pre>

<p>For example, the <code>getString</code> function that is called by invoking the <code>get</code> method is defined as the following:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">char</span>* <span class="hljs-title function_">getString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self_obj)</span>
{
    <span class="hljs-keyword">return</span> ((String)self_obj)-&gt;internal-&gt;value;
}
</code></pre>

<p>One thing that can be noticed is that there is no concept of an instance of an object and having methods that are actually a part of an object, so a "self object" must be passed in on each invocation. (And the <code>internal</code> is just a hidden <code>struct</code> which was omitted from the code listing earlier -- it is a way of performing information hiding, but that is not relevant to function pointers.)</p>

<p>So, rather than being able to do <code>s1-&gt;set("hello");</code>, one must pass in the object to perform the action on <code>s1-&gt;set(s1, "hello")</code>. </p>

<p>With that minor explanation having to pass in a reference to yourself out of the way, we'll move to the next part, which is <strong>inheritance in C</strong>.</p>

<p>Let's say we want to make a subclass of <code>String</code>, say an <code>ImmutableString</code>. In order to make the string immutable, the <code>set</code> method will not be accessible, while maintaining access to <code>get</code> and <code>length</code>, and force the "constructor" to accept a <code>char*</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ImmutableString_Struct</span>* <span class="hljs-title">ImmutableString</span>;</span>

<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ImmutableString_Struct</span>
{</span>
    String base;

    <span class="hljs-type">char</span>* (*get)(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self);
    <span class="hljs-type">int</span> (*length)(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self);
};

ImmutableString <span class="hljs-title function_">newImmutableString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span>* value)</span>;
</code></pre>

<p>Basically, for all subclasses, the available methods are once again function pointers. This time, the declaration for the <code>set</code> method is not present, therefore, it cannot be called in a <code>ImmutableString</code>.</p>

<p>As for the implementation of the <code>ImmutableString</code>, the only relevant code is the "constructor" function, the <code>newImmutableString</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">ImmutableString <span class="hljs-title function_">newImmutableString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span>* value)</span>
{
    ImmutableString self = (ImmutableString)<span class="hljs-built_in">malloc</span>(<span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">struct</span> ImmutableString_Struct));

    self-&gt;base = newString();

    self-&gt;get = self-&gt;base-&gt;get;
    self-&gt;length = self-&gt;base-&gt;length;

    self-&gt;base-&gt;<span class="hljs-built_in">set</span>(self-&gt;base, (<span class="hljs-type">char</span>*)value);

    <span class="hljs-keyword">return</span> self;
}
</code></pre>

<p>In instantiating the <code>ImmutableString</code>, the function pointers to the <code>get</code> and <code>length</code> methods actually refer to the <code>String.get</code> and <code>String.length</code> method, by going through the <code>base</code> variable which is an internally stored <code>String</code> object.</p>

<p>The use of a function pointer can achieve inheritance of a method from a superclass.</p>

<p>We can further continue to <strong>polymorphism in C</strong>.</p>

<p>If for example we wanted to change the behavior of the <code>length</code> method to return <code>0</code> all the time in the <code>ImmutableString</code> class for some reason, all that would have to be done is to:</p>

<ol>
<li>Add a function that is going to serve as the overriding <code>length</code> method.</li>
<li>Go to the "constructor" and set the function pointer to the overriding <code>length</code> method.</li>
</ol>

<p>Adding an overriding <code>length</code> method in <code>ImmutableString</code> may be performed by adding an <code>lengthOverrideMethod</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">lengthOverrideMethod</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">void</span>* self)</span>
{
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>

<p>Then, the function pointer for the <code>length</code> method in the constructor is hooked up to the <code>lengthOverrideMethod</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">ImmutableString <span class="hljs-title function_">newImmutableString</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span>* value)</span>
{
    ImmutableString self = (ImmutableString)<span class="hljs-built_in">malloc</span>(<span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">struct</span> ImmutableString_Struct));

    self-&gt;base = newString();

    self-&gt;get = self-&gt;base-&gt;get;
    self-&gt;length = &amp;lengthOverrideMethod;

    self-&gt;base-&gt;<span class="hljs-built_in">set</span>(self-&gt;base, (<span class="hljs-type">char</span>*)value);

    <span class="hljs-keyword">return</span> self;
}
</code></pre>

<p>Now, rather than having an identical behavior for the <code>length</code> method in <code>ImmutableString</code> class as the <code>String</code> class, now the <code>length</code> method will refer to the behavior defined in the <code>lengthOverrideMethod</code> function.</p>

<p>I must add a disclaimer that I am still learning how to write with an object-oriented programming style in C, so there probably are points that I didn't explain well, or may just be off mark in terms of how best to implement OOP in C. But my purpose was to try to illustrate one of many uses of function pointers.</p>

<p>For more information on how to perform object-oriented programming in C, please refer to the following questions:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/415452/object-orientation-in-c">Object-Orientation in C?</a></li>
<li><a href="https://stackoverflow.com/questions/351733/can-you-write-object-oriented-code-in-c">Can you write object oriented code in C?</a></li>
</ul>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2009-05-08T16:32:47"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="840703">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/840703" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-2" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-2"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 3.0">CC BY-SA 3.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/840703/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-840703" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-zz6nxr43">
                    Follow
                </button><div id="--stacks-s-tooltip-zz6nxr43" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/840703/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2017-05-23 12:18:30Z" class="relativetime">May 23, 2017 at 12:18</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of May 8, 2009 at 16:32. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-840703" href="https://stackoverflow.com/posts/840703/revisions" title="show revision history for this post">
        3 revs, 2 users 99%<br></a><a href="https://stackoverflow.com/users/17172">coobird</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">11</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-840703" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="840703" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="6" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-16738320" class="comment js-comment " data-comment-id="16738320" data-comment-owner-id="552014" data-comment-score="29">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">29</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">This answer is horrible! Not only it implies that OO somehow depends on dot notation, it also encourages putting junk into your objects!</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/552014/alexei-averchenko" title="1,626 reputation" class="comment-user">Alexei Averchenko</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment16738320_840703"><span title="2012-09-16 14:30:47Z, License: CC BY-SA 3.0" class="relativetime-clean">Sep 16, 2012 at 14:30</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-21924263" class="comment js-comment " data-comment-id="21924263" data-comment-owner-id="1329652" data-comment-score="32">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="supernova">32</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">This is OO all right, but not anywhere near the C-style OO. What you have brokenly implemented is Javascript-style prototype-based OO. To get C++/Pascal-style OO, you'd need to: 1. Have a const struct for a virtual table of each <i>class</i> with virtual members. 2. Have pointer to that struct in polymorphic objects. 3. Call virtual methods via the virtual table, and all other methods directly -- usually by sticking to some <code>ClassName_methodName</code> function naming convention.   Only then you get the same runtime and storage costs as you do in C++ and Pascal.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/1329652/kuba-hasnt-forgotten-monica" title="92,159 reputation" class="comment-user">Kuba hasn't forgotten Monica</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment21924263_840703"><span title="2013-03-18 21:53:15Z, License: CC BY-SA 3.0" class="relativetime-clean">Mar 18, 2013 at 21:53</span></a></span>
                        <span title="this comment was edited 3 times">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>
    <li id="comment-25392686" class="comment js-comment " data-comment-id="25392686" data-comment-owner-id="1559401" data-comment-score="20">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">20</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Working OO with a language that is not intended to be OO is always a bad idea. If you want OO and still have C just work with C++.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/1559401/rbaleksandar" title="7,632 reputation" class="comment-user">rbaleksandar</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment25392686_840703"><span title="2013-07-04 15:21:34Z, License: CC BY-SA 3.0" class="relativetime-clean">Jul 4, 2013 at 15:21</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-48055194" class="comment js-comment " data-comment-id="48055194" data-comment-owner-id="119527" data-comment-score="27">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="hot">27</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">@rbaleksandar Tell that to the Linux kernel developers. <i>"always a bad idea"</i> is strictly your opinion, with which I firmly disagree.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/119527/jonathon-reinhart" title="123,443 reputation" class="comment-user">Jonathon Reinhart</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment48055194_840703"><span title="2015-04-30 12:31:24Z, License: CC BY-SA 3.0" class="relativetime-clean">Apr 30, 2015 at 12:31</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-66840956" class="comment js-comment " data-comment-id="66840956" data-comment-owner-id="4532996" data-comment-score="7">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">7</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">I like this answer but don't cast malloc</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/4532996/cat" title="3,664 reputation" class="comment-user">cat</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment66840956_840703"><span title="2016-09-29 14:41:26Z, License: CC BY-SA 3.0" class="relativetime-clean">Sep 29, 2016 at 14:41</span></a></span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-840703" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button"></a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link " title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button">Show <b>6</b> more comments</a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="5602143"></a>
<div id="answer-5602143" class="answer js-answer" data-answerid="5602143" data-score="251" data-position-on-page="3" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/5602143/ivc/9f35?sort=4&amp;shared=0&amp;position=3&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="5602143">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-akti1ts8">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-akti1ts8" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="251">
            251
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-rwxef5h4">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-rwxef5h4" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/5602143/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-mgflxa1f"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-mgflxa1f" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>The guide to getting fired: How to abuse function pointers in GCC on x86 machines by compiling your code by hand:</p>

<p>These string literals are bytes of 32-bit x86 machine code.  <code>0xC3</code> is <a href="http://felixcloutier.com/x86/RET.html" rel="noreferrer">an x86 <code>ret</code> instruction</a>.</p>

<p>You wouldn't normally write these by hand, you'd write in assembly language and then use an assembler like <code>nasm</code> to assemble it into a flat binary which you hexdump into a C string literal.</p>

<ol>
<li><p>Returns the current value on the EAX register</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> eax = ((<span class="hljs-type">int</span>(*)())(<span class="hljs-string">"\xc3 &lt;- This returns the value of the EAX register"</span>))();
</code></pre></li>
<li><p>Write a swap function</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> a = <span class="hljs-number">10</span>, b = <span class="hljs-number">20</span>;
((<span class="hljs-type">void</span>(*)(<span class="hljs-type">int</span>*,<span class="hljs-type">int</span>*))<span class="hljs-string">"\x8b\x44\x24\x04\x8b\x5c\x24\x08\x8b\x00\x8b\x1b\x31\xc3\x31\xd8\x31\xc3\x8b\x4c\x24\x04\x89\x01\x8b\x4c\x24\x08\x89\x19\xc3 &lt;- This swaps the values of a and b"</span>)(&amp;a,&amp;b);
</code></pre></li>
<li><p>Write a for-loop counter to 1000, calling some function each time</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">((<span class="hljs-type">int</span>(*)())<span class="hljs-string">"\x66\x31\xc0\x8b\x5c\x24\x04\x66\x40\x50\xff\xd3\x58\x66\x3d\xe8\x03\x75\xf4\xc3"</span>)(&amp;function); <span class="hljs-comment">// calls function with 1-&gt;1000</span>
</code></pre></li>
<li><p>You can even write a recursive function that counts to 100</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">const</span> <span class="hljs-type">char</span>* lol = <span class="hljs-string">"\x8b\x5c\x24\x4\x3d\xe8\x3\x0\x0\x7e\x2\x31\xc0\x83\xf8\x64\x7d\x6\x40\x53\xff\xd3\x5b\xc3\xc3 &lt;- Recursively calls the function at address lol."</span>;
i = ((<span class="hljs-type">int</span>(*)())(lol))(lol);
</code></pre></li>
</ol>

<p>Note that compilers place string literals in the <code>.rodata</code> section (or <code>.rdata</code> on Windows), which is linked as part of the text segment (along with code for functions).</p>

<p>The text segment has Read+Exec permission, so casting string literals to function pointers works without needing <code>mprotect()</code> or <code>VirtualProtect()</code> system calls like you'd need for dynamically allocated memory.  (Or <code>gcc -z execstack</code> links the program with stack + data segment + heap executable, as a quick hack.)</p>

<hr>

<p>To disassemble these, you can compile this to put a label on the bytes, and use a disassembler.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-comment">// at global scope</span>
<span class="hljs-keyword">const</span> <span class="hljs-type">char</span> swap[] = <span class="hljs-string">"\x8b\x44\x24\x04\x8b\x5c\x24\x08\x8b\x00\x8b\x1b\x31\xc3\x31\xd8\x31\xc3\x8b\x4c\x24\x04\x89\x01\x8b\x4c\x24\x08\x89\x19\xc3 &lt;- This swaps the values of a and b"</span>;
</code></pre>

<p>Compiling with <code>gcc -c -m32 foo.c</code> and disassembling with <code>objdump -D -rwC -Mintel</code>, we can get the assembly, and find out that this code violates the ABI by clobbering EBX (a call-preserved register) and is generally inefficient.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-number">00000000</span> &lt;swap&gt;:
   <span class="hljs-number">0</span>:   <span class="hljs-number">8b</span> <span class="hljs-number">44</span> <span class="hljs-number">24</span> <span class="hljs-number">04</span>             mov    eax,DWORD PTR [esp+<span class="hljs-number">0x4</span>]   <span class="hljs-meta"># load int *a arg from the stack</span>
   <span class="hljs-number">4</span>:   <span class="hljs-number">8b</span> <span class="hljs-number">5</span>c <span class="hljs-number">24</span> <span class="hljs-number">08</span>             mov    ebx,DWORD PTR [esp+<span class="hljs-number">0x8</span>]   <span class="hljs-meta"># ebx = b</span>
   <span class="hljs-number">8</span>:   <span class="hljs-number">8b</span> <span class="hljs-number">00</span>                   mov    eax,DWORD PTR [eax]       <span class="hljs-meta"># dereference: eax = *a</span>
   a:   <span class="hljs-number">8b</span> <span class="hljs-number">1b</span>                   mov    ebx,DWORD PTR [ebx]
   c:   <span class="hljs-number">31</span> c3                   xor    ebx,eax                <span class="hljs-meta"># pointless xor-swap</span>
   e:   <span class="hljs-number">31</span> d8                   xor    eax,ebx                <span class="hljs-meta"># instead of just storing with opposite registers</span>
  <span class="hljs-number">10</span>:   <span class="hljs-number">31</span> c3                   xor    ebx,eax
  <span class="hljs-number">12</span>:   <span class="hljs-number">8b</span> <span class="hljs-number">4</span>c <span class="hljs-number">24</span> <span class="hljs-number">04</span>             mov    ecx,DWORD PTR [esp+<span class="hljs-number">0x4</span>]  <span class="hljs-meta"># reload a from the stack</span>
  <span class="hljs-number">16</span>:   <span class="hljs-number">89</span> <span class="hljs-number">01</span>                   mov    DWORD PTR [ecx],eax     <span class="hljs-meta"># store to *a</span>
  <span class="hljs-number">18</span>:   <span class="hljs-number">8b</span> <span class="hljs-number">4</span>c <span class="hljs-number">24</span> <span class="hljs-number">08</span>             mov    ecx,DWORD PTR [esp+<span class="hljs-number">0x8</span>]
  <span class="hljs-number">1</span>c:   <span class="hljs-number">89</span> <span class="hljs-number">19</span>                   mov    DWORD PTR [ecx],ebx
  <span class="hljs-number">1</span>e:   c3                      ret    

  not shown: the later bytes are ASCII text documentation
  they<span class="hljs-number">'</span>re not executed by the CPU because the ret instruction sends execution back to the caller
</code></pre>

<p>This machine code will (probably) work in 32-bit code on Windows, Linux, OS X, and so on: the default calling conventions on all those OSes pass args on the stack instead of more efficiently in registers.  But EBX is call-preserved in all the normal calling conventions, so using it as a scratch register without saving/restoring it can easily make the caller crash.</p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2011-04-09T00:51:16"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="5602143">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/5602143" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-3" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-3"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 4.0">CC BY-SA 4.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/5602143/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-5602143" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-sw07pzww">
                    Follow
                </button><div id="--stacks-s-tooltip-sw07pzww" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/5602143/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2018-10-09 13:58:10Z" class="relativetime">Oct 9, 2018 at 13:58</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <a href="https://stackoverflow.com/collectives/intel" class="ml4 fc-gold va-text-bottom js-gps-track fc-gold" data-controller="s-tooltip" data-s-tooltip-placement="right-end" data-gps-track="subcommunity_link.click({ subcommunity_user_type: 0, subcommunity_slug: intel, link_source: 4 })" aria-describedby="--stacks-s-tooltip-k9ulsmbh"><svg aria-hidden="true" class="svg-icon iconAchievementsSm" width="14" height="14" viewBox="0 0 14 14"><path d="M11 2V1H3v1H0v3c0 1.6 1.4 3 3 3 0 0 .5 2 3 2v1H4s-1 1.5-1 2h8c0-.4-1-2-1-2H8v-1c2.5 0 3-2 3-2 1.6-.2 3-1.4 3-3V2h-3ZM3 6c-.5 0-1-.5-1-1V4h1v2Zm9-1c0 .5-.5 1-1 1V4h1v1ZM7 7a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z"></path></svg></a><div id="--stacks-s-tooltip-k9ulsmbh" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This user is first on the weekly Intel leaderboard.<div class="s-popover--arrow"></div></div>
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Apr 9, 2011 at 0:51. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-5602143" href="https://stackoverflow.com/posts/5602143/revisions" title="show revision history for this post">
        4 revs, 3 users 50%<br></a><a href="https://stackoverflow.com/users/510991">Lee</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">19</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-5602143" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="5602143" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="14" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-20771937" class="comment js-comment " data-comment-id="20771937" data-comment-owner-id="1250976" data-comment-score="9">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">9</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Note: this doesn't work if Data Execution Prevention is enabled (e.g. on Windows XP SP2+), because C strings are not normally marked as executable.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/1250976/securitymatt" title="6,265 reputation" class="comment-user">SecurityMatt</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment20771937_5602143"><span title="2013-02-12 05:53:45Z, License: CC BY-SA 3.0" class="relativetime-clean">Feb 12, 2013 at 5:53</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-31328400" class="comment js-comment " data-comment-id="31328400" data-comment-owner-id="510991" data-comment-score="5">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">5</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Hi Matt! Depending on the optimization level, GCC will often inline string constants into the TEXT segment, so this will work even on newer version of windows provided that you don't disallow this type of optimization. (IIRC, the MINGW version at the time of my post over two years ago inlines string literals at the default optimization level)</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/510991/lee" title="472 reputation" class="comment-user">Lee</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment31328400_5602143"><span title="2014-01-02 06:20:51Z, License: CC BY-SA 3.0" class="relativetime-clean">Jan 2, 2014 at 6:20</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-31979406" class="comment js-comment " data-comment-id="31979406" data-comment-owner-id="1809377" data-comment-score="11">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">11</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">could someone please explain what's happening here? What are those weird looking string literals?</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/1809377/ajay" title="8,959 reputation" class="comment-user">ajay</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment31979406_5602143"><span title="2014-01-20 10:17:40Z, License: CC BY-SA 3.0" class="relativetime-clean">Jan 20, 2014 at 10:17</span></a></span>
                        <span title="this comment was edited 1 time">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>
    <li id="comment-33246027" class="comment js-comment " data-comment-id="33246027" data-comment-owner-id="2528962" data-comment-score="62">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="supernova">62</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">@ajay It looks like he's writing raw hexidecimal values (for instance '\x00' is the same as '/0', they're both equal to 0) into a string, then casting the string into a C function pointer, then executing the C function pointer because he's the devil.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/2528962/ejk314" title="381 reputation" class="comment-user">ejk314</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment33246027_5602143"><span title="2014-02-21 21:27:59Z, License: CC BY-SA 3.0" class="relativetime-clean">Feb 21, 2014 at 21:27</span></a></span>
                        <span title="this comment was edited 1 time">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>
    <li id="comment-33999736" class="comment js-comment " data-comment-id="33999736" data-comment-owner-id="510991" data-comment-score="4">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="cool">4</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">hi FUZxxl, I think it might vary based on the compiler and the operating system version. The above code seems to run fine on codepad.org; <a href="http://codepad.org/FMSDQ3ME" rel="nofollow noreferrer">codepad.org/FMSDQ3ME</a></span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/510991/lee" title="472 reputation" class="comment-user">Lee</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment33999736_5602143"><span title="2014-03-13 00:48:21Z, License: CC BY-SA 3.0" class="relativetime-clean">Mar 13, 2014 at 0:48</span></a></span>
                        <span title="this comment was edited 1 time">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-5602143" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button"></a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link " title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button">Show <b>14</b> more comments</a>
        </div>         
    </div>
    </div>
</div>
<div class="js-zone-container zone-container-main">
    <div id="dfp-smlb" class="everyonelovesstackoverflow everyoneloves__mid-second-leaderboard everyoneloves__leaderboard" data-clc-prefilled="true" style="min-height: auto; height: auto; display: none;" data-google-query-id="CLmEj62_6PYCFQ3SmgodEMoG6Q" data-clc-ready="true"><div id="google_ads_iframe_/248424177/stackoverflow.com/smlb/question-pages_0__container__" style="border: 0pt none; width: 728px; height: auto; min-height: auto; display: none;"></div></div>
    <div class="js-report-ad-button-container " style="width: 728px"></div>
</div>
                                          
<a name="840669"></a>
<div id="answer-840669" class="answer js-answer" data-answerid="840669" data-score="120" data-position-on-page="4" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/840669/ivc/9f35?sort=4&amp;shared=0&amp;position=4&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="840669">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-q3y6bv06">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-q3y6bv06" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="120">
            120
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-21kydy8f">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-21kydy8f" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/840669/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-sot6l1xq"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-sot6l1xq" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>One of my favorite uses for function pointers is as cheap and easy iterators - </p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">define</span> MAX_COLORS  256</span>

<span class="hljs-keyword">typedef</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> {</span>
    <span class="hljs-type">char</span>* name;
    <span class="hljs-type">int</span> red;
    <span class="hljs-type">int</span> green;
    <span class="hljs-type">int</span> blue;
} Color;

Color Colors[MAX_COLORS];


<span class="hljs-type">void</span> <span class="hljs-title function_">eachColor</span> <span class="hljs-params">(<span class="hljs-type">void</span> (*fp)(Color *c))</span> {
    <span class="hljs-type">int</span> i;
    <span class="hljs-keyword">for</span> (i=<span class="hljs-number">0</span>; i&lt;MAX_COLORS; i++)
        (*fp)(&amp;Colors[i]);
}

<span class="hljs-type">void</span> <span class="hljs-title function_">printColor</span><span class="hljs-params">(Color* c)</span> {
    <span class="hljs-keyword">if</span> (c-&gt;name)
        <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s = %i,%i,%i\n"</span>, c-&gt;name, c-&gt;red, c-&gt;green, c-&gt;blue);
}

<span class="hljs-type">int</span> <span class="hljs-title function_">main</span><span class="hljs-params">()</span> {
    Colors[<span class="hljs-number">0</span>].name=<span class="hljs-string">"red"</span>;
    Colors[<span class="hljs-number">0</span>].red=<span class="hljs-number">255</span>;
    Colors[<span class="hljs-number">1</span>].name=<span class="hljs-string">"blue"</span>;
    Colors[<span class="hljs-number">1</span>].blue=<span class="hljs-number">255</span>;
    Colors[<span class="hljs-number">2</span>].name=<span class="hljs-string">"black"</span>;

    eachColor(printColor);
}
</code></pre>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2009-05-08T16:26:09"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="840669">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/840669" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-4" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-4"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 3.0">CC BY-SA 3.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/840669/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-840669" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-zqpi9kg0">
                    Follow
                </button><div id="--stacks-s-tooltip-zqpi9kg0" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/840669/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2012-07-24 16:40:57Z" class="relativetime">Jul 24, 2012 at 16:40</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of May 8, 2009 at 16:26. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-840669" href="https://stackoverflow.com/posts/840669/revisions" title="show revision history for this post">
        2 revs, 2 users 99%<br></a><a href="https://stackoverflow.com/users/30470">Nick</a>

        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">2</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-840669" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="840669" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-16738345" class="comment js-comment " data-comment-id="16738345" data-comment-owner-id="552014" data-comment-score="9">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">9</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">You should also pass a pointer to user-specified data if you want to somehow extract any output from iterations (think closures).</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/552014/alexei-averchenko" title="1,626 reputation" class="comment-user">Alexei Averchenko</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment16738345_840669"><span title="2012-09-16 14:32:52Z, License: CC BY-SA 3.0" class="relativetime-clean">Sep 16, 2012 at 14:32</span></a></span>
            </div>
        </div>
    </li>
    <li id="comment-48055341" class="comment js-comment " data-comment-id="48055341" data-comment-owner-id="119527" data-comment-score="3">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="cool">3</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">Agreed. All of my iterators look like this: <code>int (*cb)(void *arg, ...)</code>.  The return value of the iterator also lets me stop early (if nonzero).</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/119527/jonathon-reinhart" title="123,443 reputation" class="comment-user">Jonathon Reinhart</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment48055341_840669"><span title="2015-04-30 12:35:25Z, License: CC BY-SA 3.0" class="relativetime-clean">Apr 30, 2015 at 12:35</span></a></span>
                        <span title="this comment was edited 1 time">
                            <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>
                        </span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-840669" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="842503"></a>
<div id="answer-842503" class="answer js-answer" data-answerid="842503" data-score="25" data-position-on-page="5" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/842503/ivc/9f35?sort=4&amp;shared=0&amp;position=5&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="842503">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-oidbwomv">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-oidbwomv" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="25">
            25
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-vld6gi4u">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-vld6gi4u" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/842503/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-tu3br2z1"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-tu3br2z1" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>Function pointers become easy to declare once you have the basic declarators:</p>

<ul>
<li>id: <code>ID</code>: <em>ID is a</em></li>
<li>Pointer: <code>*D</code>: <em>D pointer to</em></li>
<li>Function: <code>D(&lt;parameters&gt;)</code>: <em>D function taking <code>&lt;</code>parameters<code>&gt;</code> returning</em></li>
</ul>

<p>While D is another declarator built using those same rules. In the end, somewhere, it ends with <code>ID</code> (see below for an example), which is the name of the declared entity. Let's try to build a function taking a pointer to a function taking nothing and returning int, and returning a pointer to a function taking a char and returning int. With type-defs it's like this</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-type">int</span> <span class="hljs-title function_">ReturnFunction</span><span class="hljs-params">(<span class="hljs-type">char</span>)</span>;
<span class="hljs-keyword">typedef</span> <span class="hljs-type">int</span> <span class="hljs-title function_">ParameterFunction</span><span class="hljs-params">(<span class="hljs-type">void</span>)</span>;
ReturnFunction *<span class="hljs-title function_">f</span><span class="hljs-params">(ParameterFunction *p)</span>;
</code></pre>

<p>As you see, it's pretty easy to build it up using typedefs. Without typedefs, it's not hard either with the above declarator rules, applied consistently. As you see i missed out the part the pointer points to, and the thing the function returns. That's what appears at the very left of the declaration, and is not of interest: It's added at the end if one built up the declarator already. Let's do that. Building it up consistently, first wordy - showing the structure using <code>[</code> and <code>]</code>:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">function taking 
    [pointer to [function taking [<span class="hljs-type">void</span>] returning [<span class="hljs-type">int</span>]]] 
returning
    [pointer to [function taking [<span class="hljs-type">char</span>] returning [<span class="hljs-type">int</span>]]]
</code></pre>

<p>As you see, one can describe a type completely by appending declarators one after each other. Construction can be done in two ways. One is bottom-up, starting with the very right thing (leaves) and working the way through up to the identifier. The other way is top-down, starting at the identifier, working the way down to the leaves. I'll show both ways.</p>

<h2>Bottom Up</h2>

<p>Construction starts with the thing at the right: The thing returned, which is the function taking char. To keep the declarators distinct, i'm going to number them:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">D1(<span class="hljs-type">char</span>);
</code></pre>

<p>Inserted the char parameter directly, since it's trivial. Adding a pointer to declarator by replacing <code>D1</code> by <code>*D2</code>. Note that we have to wrap parentheses around <code>*D2</code>. That can be known by looking up the precedence of the <code>*-operator</code> and the function-call operator <code>()</code>. Without our parentheses, the compiler would read it as <code>*(D2(char p))</code>. But that would not be a plain replace of D1 by <code>*D2</code> anymore, of course. Parentheses are always allowed around declarators. So you don't make anything wrong if you add too much of them, actually.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">(*D2)(<span class="hljs-type">char</span>);
</code></pre>

<p>Return type is complete! Now, let's replace <code>D2</code> by the function declarator <em>function taking <code>&lt;parameters&gt;</code> returning</em>, which is <code>D3(&lt;parameters&gt;)</code> which we are at now. </p>

<pre class="lang-c s-code-block"><code class="hljs language-c">(*D3(&lt;parameters&gt;))(<span class="hljs-type">char</span>)
</code></pre>

<p>Note that no parentheses are needed, since we <em>want</em> <code>D3</code> to be a function-declarator and not a pointer declarator this time. Great, only thing left is the parameters for it. The parameter is done exactly the same as we've done the return type, just with <code>char</code> replaced by <code>void</code>. So i'll copy it:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">(*D3(   (*ID1)(<span class="hljs-type">void</span>)))(<span class="hljs-type">char</span>)
</code></pre>

<p>I've replaced <code>D2</code> by <code>ID1</code>, since we are finished with that parameter (it's already a pointer to a function - no need for another declarator). <code>ID1</code> will be the name of the parameter. Now, i told above at the end one adds the type which all those declarator modify - the one appearing at the very left of every declaration. For functions, that becomes the return type. For pointers the pointed to type etc... It's interesting when written down the type, it will appear in the opposite order, at the very right :) Anyway, substituting it yields the complete declaration. Both times <code>int</code> of course. </p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> (*ID0(<span class="hljs-type">int</span> (*ID1)(<span class="hljs-type">void</span>)))(<span class="hljs-type">char</span>)
</code></pre>

<p>I've called the identifier of the function <code>ID0</code> in that example. </p>

<h2>Top Down</h2>

<p>This starts at the identifier at the very left in the description of the type, wrapping that declarator as we walk our way through the right. Start with <em>function taking <code>&lt;</code>parameters<code>&gt;</code> returning</em></p>

<pre class="lang-c s-code-block"><code class="hljs language-c">ID0(&lt;parameters&gt;)
</code></pre>

<p>The next thing in the description (after "returning") was <em>pointer to</em>. Let's incorporate it:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">*ID0(&lt;parameters&gt;)
</code></pre>

<p>Then the next thing was <em>functon taking <code>&lt;</code>parameters<code>&gt;</code> returning</em>. The parameter is a simple char, so we put it in right away again, since it's really trivial.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">(*ID0(&lt;parameters&gt;))(<span class="hljs-type">char</span>)
</code></pre>

<p>Note the parentheses we added, since we again want that the <code>*</code> binds first, and <em>then</em> the <code>(char)</code>. Otherwise it would read <em>function taking <code>&lt;</code>parameters<code>&gt;</code> returning function ...</em>. Noes, functions returning functions aren't even allowed. </p>

<p>Now we just need to put <code>&lt;</code>parameters<code>&gt;</code>. I will show a short version of the deriveration, since i think you already by now have the idea how to do it.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">pointer to: *ID1
... function taking <span class="hljs-type">void</span> returning: (*ID1)(<span class="hljs-type">void</span>)
</code></pre>

<p>Just put <code>int</code> before the declarators like we did with bottom-up, and we are finished</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> (*ID0(<span class="hljs-type">int</span> (*ID1)(<span class="hljs-type">void</span>)))(<span class="hljs-type">char</span>)
</code></pre>

<h2>The nice thing</h2>

<p>Is bottom-up or top-down better? I'm used to bottom-up, but some people may be more comfortable with top-down. It's a matter of taste i think. Incidentally, if you apply all the operators in that declaration, you will end up getting an int:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> v = (*ID0(some_function_pointer))(some_char);
</code></pre>

<p>That is a nice property of declarations in C: The declaration asserts that if those operators are used in an expression using the identifier, then it yields the type on the very left. It's like that for arrays too. </p>

<p>Hope you liked this little tutorial! Now we can link to this when people wonder about the strange declaration syntax of functions. I tried to put as little C internals as possible. Feel free to edit/fix things in it. </p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2009-05-09T02:05:44"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="842503">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/842503" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-5" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-5"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/2.5/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 2.5">CC BY-SA 2.5</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/842503/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-842503" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-ko33ky27">
                    Follow
                </button><div id="--stacks-s-tooltip-ko33ky27" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/842503/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2009-05-09 13:38:17Z" class="relativetime">May 9, 2009 at 13:38</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of May 9, 2009 at 2:05. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-842503" href="https://stackoverflow.com/posts/842503/revisions" title="show revision history for this post">
        3 revs<br></a><a href="https://stackoverflow.com/users/34509">Johannes Schaub - litb</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount"></span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-842503" class="comments js-comments-container bt bc-black-075 mt12  dno" data-post-id="842503" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

            </ul>
	    </div>

        <div id="comments-link-842503" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="17031775"></a>
<div id="answer-17031775" class="answer js-answer" data-answerid="17031775" data-score="24" data-position-on-page="6" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/17031775/ivc/9f35?sort=4&amp;shared=0&amp;position=6&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="17031775">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-70wck8i9">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-70wck8i9" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="24">
            24
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-3oisgena">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-3oisgena" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/17031775/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-646zv4tg"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-646zv4tg" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<h2>Another good use for function pointers:<br>Switching between versions painlessly</h2>

<p>They're very handy to use for when you want different functions at different times, or different phases of development. For instance, I'm developing an application on a host computer that has a console, but the final release of the software will be put on an Avnet ZedBoard (which has ports for displays and consoles, but they are not needed/wanted for the final release). So during development, I will use <code>printf</code> to view status and error messages, but when I'm done, I don't want anything printed. Here's what I've done:</p>

<h1>version.h</h1>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-comment">// First, undefine all macros associated with version.h</span>
<span class="hljs-meta">#<span class="hljs-keyword">undef</span> DEBUG_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">undef</span> RELEASE_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">undef</span> INVALID_VERSION</span>


<span class="hljs-comment">// Define which version we want to use</span>
<span class="hljs-meta">#<span class="hljs-keyword">define</span> DEBUG_VERSION       <span class="hljs-comment">// The current version</span></span>
<span class="hljs-comment">// #define RELEASE_VERSION  // To be uncommented when finished debugging</span>

<span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> __VERSION_H_      <span class="hljs-comment">/* prevent circular inclusions */</span></span>
    <span class="hljs-meta">#<span class="hljs-keyword">define</span> __VERSION_H_  <span class="hljs-comment">/* by using protection macros */</span></span>
    <span class="hljs-type">void</span> <span class="hljs-title function_">board_init</span><span class="hljs-params">()</span>;
    <span class="hljs-type">void</span> <span class="hljs-title function_">noprintf</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span> *c, ...)</span>; <span class="hljs-comment">// mimic the printf prototype</span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>

<span class="hljs-comment">// Mimics the printf function prototype. This is what I'll actually </span>
<span class="hljs-comment">// use to print stuff to the screen</span>
<span class="hljs-type">void</span> (* zprintf)(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span>*, ...); 

<span class="hljs-comment">// If debug version, use printf</span>
<span class="hljs-meta">#<span class="hljs-keyword">ifdef</span> DEBUG_VERSION</span>
    <span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>

<span class="hljs-comment">// If both debug and release version, error</span>
<span class="hljs-meta">#<span class="hljs-keyword">ifdef</span> DEBUG_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">ifdef</span> RELEASE_VERSION</span>
    <span class="hljs-meta">#<span class="hljs-keyword">define</span> INVALID_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>

<span class="hljs-comment">// If neither debug or release version, error</span>
<span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> DEBUG_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> RELEASE_VERSION</span>
    <span class="hljs-meta">#<span class="hljs-keyword">define</span> INVALID_VERSION</span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>

<span class="hljs-meta">#<span class="hljs-keyword">ifdef</span> INVALID_VERSION</span>
    <span class="hljs-comment">// Won't allow compilation without a valid version define</span>
    <span class="hljs-meta">#<span class="hljs-keyword">error</span> <span class="hljs-string">"Invalid version definition"</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>
</code></pre>

<p>In <code>version.c</code> I will define the 2 function prototypes present in <code>version.h</code></p>

<h1>version.c</h1>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">"version.h"</span></span>

<span class="hljs-comment">/*****************************************************************************/</span>
<span class="hljs-comment">/**
* @name board_init
*
* Sets up the application based on the version type defined in version.h.
* Includes allowing or prohibiting printing to STDOUT.
*
* MUST BE CALLED FIRST THING IN MAIN
*
* @return    None
*
*****************************************************************************/</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">board_init</span><span class="hljs-params">()</span>
{
    <span class="hljs-comment">// Assign the print function to the correct function pointer</span>
    <span class="hljs-meta">#<span class="hljs-keyword">ifdef</span> DEBUG_VERSION</span>
        zprintf = &amp;<span class="hljs-built_in">printf</span>;
    <span class="hljs-meta">#<span class="hljs-keyword">else</span></span>
        <span class="hljs-comment">// Defined below this function</span>
        zprintf = &amp;noprintf;
    <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>
}

<span class="hljs-comment">/*****************************************************************************/</span>
<span class="hljs-comment">/**
* @name noprintf
*
* simply returns with no actions performed
*
* @return   None
*
*****************************************************************************/</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">noprintf</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-type">char</span>* c, ...)</span>
{
    <span class="hljs-keyword">return</span>;
}
</code></pre>

<p></p><p>Notice how the function pointer is prototyped in <code>version.h</code> as </p><p><code>void (* zprintf)(const char *, ...);</code></p><p>When it is referenced in the application, it will start executing wherever it is pointing, which has yet to be defined.</p>
<p>In <code>version.c</code>, notice in the <code>board_init()</code>function where <code>zprintf</code> is assigned a unique function (whose function signature matches) depending on the version that is defined in <code>version.h</code></p><p><code>zprintf = &amp;printf;</code> zprintf calls printf for debugging purposes</p><p>or</p><p><code>zprintf = &amp;noprint;</code> zprintf just returns and will not run unnecessary code</p><p></p>

<p>Running the code will look like this:</p>

<h1>mainProg.c</h1>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">"version.h"</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;stdlib.h&gt;</span></span>
<span class="hljs-type">int</span> <span class="hljs-title function_">main</span><span class="hljs-params">()</span>
{
    <span class="hljs-comment">// Must run board_init(), which assigns the function</span>
    <span class="hljs-comment">// pointer to an actual function</span>
    board_init();

    <span class="hljs-type">void</span> *ptr = <span class="hljs-built_in">malloc</span>(<span class="hljs-number">100</span>); <span class="hljs-comment">// Allocate 100 bytes of memory</span>
    <span class="hljs-comment">// malloc returns NULL if unable to allocate the memory.</span>

    <span class="hljs-keyword">if</span> (ptr == <span class="hljs-literal">NULL</span>)
    {
        zprintf(<span class="hljs-string">"Unable to allocate memory\n"</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
    }

    <span class="hljs-comment">// Other things to do...</span>
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>

<p>The above code will use <code>printf</code> if in debug mode, or do nothing if in release mode. This is much easier than going through the entire project and commenting out or deleting code. All that I need to do is change the version in <code>version.h</code> and the code will do the rest!</p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2013-06-10T19:56:41"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="17031775">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/17031775" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-6" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-6"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 3.0">CC BY-SA 3.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/17031775/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-17031775" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-1whuyxfq">
                    Follow
                </button><div id="--stacks-s-tooltip-1whuyxfq" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/17031775/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2013-06-11 15:36:22Z" class="relativetime">Jun 11, 2013 at 15:36</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Jun 10, 2013 at 19:56. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-17031775" href="https://stackoverflow.com/posts/17031775/revisions" title="show revision history for this post">
        2 revs<br></a><a href="https://stackoverflow.com/users/2321661">Zack Sheffield</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">1</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-17031775" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="17031775" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-87603633" class="comment js-comment " data-comment-id="87603633" data-comment-owner-id="5753034" data-comment-score="6">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
                    <span title="number of &#39;useful comment&#39; votes received" class="warm">6</span>
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">U stand to lose a lot of performance time. Instead you could use a macro that enables and disables a section of code based on Debug / Release.</span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/5753034/alphagoku" title="870 reputation" class="comment-user">AlphaGoku</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment87603633_17031775"><span title="2018-05-11 13:41:45Z, License: CC BY-SA 4.0" class="relativetime-clean">May 11, 2018 at 13:41</span></a></span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-17031775" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="26839889"></a>
<div id="answer-26839889" class="answer js-answer" data-answerid="26839889" data-score="20" data-position-on-page="7" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/26839889/ivc/9f35?sort=4&amp;shared=0&amp;position=7&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="26839889">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-x3z2i3y4">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-x3z2i3y4" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="20">
            20
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-huh88xg4">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-huh88xg4" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/26839889/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-qpcnnzv0"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-qpcnnzv0" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>Function pointer is usually defined by <code>typedef</code>, and used as param &amp; return value.</p>

<p>Above answers already explained a lot, I just give a full example:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;stdio.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-keyword">define</span> NUM_A 1</span>
<span class="hljs-meta">#<span class="hljs-keyword">define</span> NUM_B 2</span>

<span class="hljs-comment">// define a function pointer type</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-title function_">int</span> <span class="hljs-params">(*two_num_operation)</span><span class="hljs-params">(<span class="hljs-type">int</span>, <span class="hljs-type">int</span>)</span>;

<span class="hljs-comment">// an actual standalone function</span>
<span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">sum</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)</span> {
    <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-comment">// use function pointer as param,</span>
<span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">sum_via_pointer</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, two_num_operation funp)</span> {
    <span class="hljs-keyword">return</span> (*funp)(a, b);
}

<span class="hljs-comment">// use function pointer as return value,</span>
<span class="hljs-keyword">static</span> two_num_operation <span class="hljs-title function_">get_sum_fun</span><span class="hljs-params">()</span> {
    <span class="hljs-keyword">return</span> &amp;sum;
}

<span class="hljs-comment">// test - use function pointer as variable,</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">test_pointer_as_variable</span><span class="hljs-params">()</span> {
    <span class="hljs-comment">// create a pointer to function,</span>
    two_num_operation sum_p = &amp;sum;
    <span class="hljs-comment">// call function via pointer</span>
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"pointer as variable:\t %d + %d = %d\n"</span>, NUM_A, NUM_B, (*sum_p)(NUM_A, NUM_B));
}

<span class="hljs-comment">// test - use function pointer as param,</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">test_pointer_as_param</span><span class="hljs-params">()</span> {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"pointer as param:\t %d + %d = %d\n"</span>, NUM_A, NUM_B, sum_via_pointer(NUM_A, NUM_B, &amp;sum));
}

<span class="hljs-comment">// test - use function pointer as return value,</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">test_pointer_as_return_value</span><span class="hljs-params">()</span> {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"pointer as return value:\t %d + %d = %d\n"</span>, NUM_A, NUM_B, (*get_sum_fun())(NUM_A, NUM_B));
}

<span class="hljs-type">int</span> <span class="hljs-title function_">main</span><span class="hljs-params">()</span> {
    test_pointer_as_variable();
    test_pointer_as_param();
    test_pointer_as_return_value();

    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2014-11-10T08:50:57"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="26839889">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/26839889" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-7" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-7"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 4.0">CC BY-SA 4.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/26839889/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-26839889" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-urzxm1uf">
                    Follow
                </button><div id="--stacks-s-tooltip-urzxm1uf" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/26839889/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2019-06-08 06:56:02Z" class="relativetime">Jun 8, 2019 at 6:56</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Nov 10, 2014 at 8:50. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-26839889" href="https://stackoverflow.com/posts/26839889/revisions" title="show revision history for this post">
        2 revs, 2 users 99%<br></a><a href="https://stackoverflow.com/users/1568658">Eric Wang</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount"></span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-26839889" class="comments js-comments-container bt bc-black-075 mt12  dno" data-post-id="26839889" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

            </ul>
	    </div>

        <div id="comments-link-26839889" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="26979318"></a>
<div id="answer-26979318" class="answer js-answer" data-answerid="26979318" data-score="17" data-position-on-page="8" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/26979318/ivc/9f35?sort=4&amp;shared=0&amp;position=8&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="26979318">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-m71crsjy">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-m71crsjy" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="17">
            17
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-rc6bp9jf">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-rc6bp9jf" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/26979318/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-m63vro0d"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-m63vro0d" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>One of the big uses for function pointers in C is to call a function selected at run-time. For example, the C run-time library has two routines, <a href="https://en.cppreference.com/w/c/algorithm/qsort" rel="noreferrer"><code>qsort</code></a> and <a href="https://en.cppreference.com/w/c/algorithm/bsearch" rel="noreferrer"><code>bsearch</code></a>, which take a pointer to a function that is called to compare two items being sorted; this allows you to sort or search, respectively, anything, based on any criteria you wish to use. </p>

<p>A very basic example, if there is one function called <code>print(int x, int y)</code> which in turn may require to call a function (either <code>add()</code> or <code>sub()</code>, which are of the same type) then what we will do, we will add one function pointer argument to the <code>print()</code> function as shown below:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;stdio.h&gt;</span></span>

<span class="hljs-type">int</span> <span class="hljs-title function_">add</span><span class="hljs-params">()</span>
{
   <span class="hljs-keyword">return</span> (<span class="hljs-number">100</span>+<span class="hljs-number">10</span>);
}

<span class="hljs-type">int</span> <span class="hljs-title function_">sub</span><span class="hljs-params">()</span>
{
   <span class="hljs-keyword">return</span> (<span class="hljs-number">100</span><span class="hljs-number">-10</span>);
}

<span class="hljs-type">void</span> <span class="hljs-title function_">print</span><span class="hljs-params">(<span class="hljs-type">int</span> x, <span class="hljs-type">int</span> y, <span class="hljs-type">int</span> (*func)())</span>
{
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"value is: %d\n"</span>, (x+y+(*func)()));
}

<span class="hljs-type">int</span> <span class="hljs-title function_">main</span><span class="hljs-params">()</span>
{
    <span class="hljs-type">int</span> x=<span class="hljs-number">100</span>, y=<span class="hljs-number">200</span>;
    print(x,y,add);
    print(x,y,sub);

    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>

<p>The output is:</p>

<blockquote>
  <p>value is: 410<br>
  value is: 390</p>
</blockquote>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2014-11-17T18:24:09"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="26979318">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/26979318" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-8" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-8"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 4.0">CC BY-SA 4.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/26979318/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-26979318" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-46dpo1p3">
                    Follow
                </button><div id="--stacks-s-tooltip-46dpo1p3" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/26979318/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2019-03-13 17:09:26Z" class="relativetime">Mar 13, 2019 at 17:09</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Nov 17, 2014 at 18:24. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-26979318" href="https://stackoverflow.com/posts/26979318/revisions" title="show revision history for this post">
        3 revs, 3 users 76%<br></a><a href="https://stackoverflow.com/users/2381088">Vamsi</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount"></span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-26979318" class="comments js-comments-container bt bc-black-075 mt12  dno" data-post-id="26979318" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

            </ul>
	    </div>

        <div id="comments-link-26979318" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="26054925"></a>
<div id="answer-26054925" class="answer js-answer" data-answerid="26054925" data-score="17" data-position-on-page="9" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/26054925/ivc/9f35?sort=4&amp;shared=0&amp;position=9&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="26054925">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-cz6gntli">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-cz6gntli" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="17">
            17
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-57no6lg6">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-57no6lg6" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/26054925/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-zzno05st"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-zzno05st" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>Starting from scratch function has Some Memory Address From Where They start executing. In Assembly Language They Are called as (call "function's memory address").Now come back to C If function has a memory address then they can be manipulated by Pointers in C.So By the rules of C </p>

<p>1.First you need to declare a pointer to function 
2.Pass the Address of the  Desired function </p>

<p>****Note-&gt;the functions should be of same type**** </p>

<p>This Simple Programme will Illustrate Every Thing.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span><span class="hljs-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-type">void</span> (*print)() ;<span class="hljs-comment">//Declare a  Function Pointers</span>
<span class="hljs-type">void</span> <span class="hljs-title function_">sayhello</span><span class="hljs-params">()</span>;<span class="hljs-comment">//Declare The Function Whose Address is to be passed</span>
                <span class="hljs-comment">//The Functions should Be of Same Type</span>
<span class="hljs-type">int</span> <span class="hljs-title function_">main</span><span class="hljs-params">()</span>
{
 print=sayhello;<span class="hljs-comment">//Addressof sayhello is assigned to print</span>
 print();<span class="hljs-comment">//print Does A call To The Function </span>
 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}

<span class="hljs-type">void</span> <span class="hljs-title function_">sayhello</span><span class="hljs-params">()</span>
{
 <span class="hljs-built_in">printf</span>(<span class="hljs-string">"\n Hello World"</span>);
}
</code></pre>

<p><img src="./How do function pointers in C work_ - Stack Overflow_files/L4qpJ.png" alt="enter image description here">After That lets See How machine Understands Them.Glimpse of machine instruction of the above programme in 32 bit architecture.</p>

<p>The red mark area is showing how the address is being exchanged and storing in eax. Then their is a call instruction on eax. eax contains the desired address of the function.</p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2014-09-26T08:09:51"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="26054925">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/26054925" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-9" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-9"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 4.0">CC BY-SA 4.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/26054925/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-26054925" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-7w61jxb4">
                    Follow
                </button><div id="--stacks-s-tooltip-7w61jxb4" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        <a href="https://stackoverflow.com/posts/26054925/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title="2019-06-08 06:56:44Z" class="relativetime">Jun 8, 2019 at 6:56</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Sep 26, 2014 at 8:09. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-26054925" href="https://stackoverflow.com/posts/26054925/revisions" title="show revision history for this post">
        2 revs, 2 users 97%<br></a><a href="https://stackoverflow.com/users/1485906">Mohit Dabas</a>
        
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">1</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-26054925" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="26054925" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <li id="comment-118697658" class="comment js-comment " data-comment-id="118697658" data-comment-owner-id="4441547" data-comment-score="0">
        <div class="js-comment-actions comment-actions">
            <div class="comment-score js-comment-edit-hide">
            </div>
        </div>
        <div class="comment-text  js-comment-text-and-form">
            <div class="comment-body js-comment-edit-hide">
                
                <span class="comment-copy">How do I use a function pointer returned from a method? <code>something()</code> seems to just crash the program. I have some context and failed code here: <a href="https://stackoverflow.com/questions/67152106/">stackoverflow.com/questions/67152106</a></span>
                
              <div class="d-inline-flex ai-center">
–&nbsp;<a href="https://stackoverflow.com/users/4441547/aaron-franke" title="2,335 reputation" class="comment-user">Aaron Franke</a>
                </div>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#comment118697658_26054925"><span title="2021-04-18 18:41:06Z, License: CC BY-SA 4.0" class="relativetime-clean">Apr 18, 2021 at 18:41</span></a></span>
            </div>
        </div>
    </li>

            </ul>
	    </div>

        <div id="comments-link-26054925" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="51924748"></a>
<div id="answer-51924748" class="answer js-answer" data-answerid="51924748" data-score="15" data-position-on-page="10" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/51924748/ivc/9f35?sort=4&amp;shared=0&amp;position=10&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="51924748">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-x9euxc58">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-x9euxc58" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="15">
            15
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-5d3afpv6">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-5d3afpv6" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/51924748/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-z4knwjfn"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-z4knwjfn" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>A function pointer is a variable that contains the address of a function. Since it is a pointer variable though with some restricted properties, you can use it pretty much like you would any other pointer variable in data structures.</p>

<p>The only exception I can think of is treating the function pointer as pointing to something other than a single value. Doing pointer arithmetic by incrementing or decrementing a function pointer or adding/subtracting an offset to a function pointer isn't really of any utility as a function pointer only points to a single thing, the entry point of a function.</p>

<p>The size of a function pointer variable, the number of bytes occupied by the variable, may vary depending on the underlying architecture, e.g. x32 or x64 or whatever.</p>

<p>The declaration for a function pointer variable needs to specify the same kind of information as a function declaration in order for the C compiler to do the kinds of checks that it normally does. If you don't specify a parameter list in the declaration/definition of the function pointer, the C compiler will not be able to check the use of parameters. There are cases when this lack of checking can be useful however just remember that a safety net has been removed.</p>

<p>Some examples:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">func</span> <span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr)</span>;    <span class="hljs-comment">// declares a function</span>

<span class="hljs-type">int</span> (*pFunc)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr);  <span class="hljs-comment">// declares or defines a function pointer</span>

<span class="hljs-type">int</span> (*pFunc2) ();                 <span class="hljs-comment">// declares or defines a function pointer, no parameter list specified.</span>

<span class="hljs-type">int</span> (*pFunc3) (<span class="hljs-type">void</span>);             <span class="hljs-comment">// declares or defines a function pointer, no arguments.</span>
</code></pre>

<p>The first two declararations are somewhat similar in that:</p>

<ul>
<li><code>func</code> is a function that takes an <code>int</code> and a <code>char *</code> and returns an <code>int</code></li>
<li><code>pFunc</code> is a function pointer to which is assigned the address of a function that takes an <code>int</code> and a <code>char *</code> and returns an <code>int</code></li>
</ul>

<p>So from the above we could have a source line in which the address of the function <code>func()</code> is assigned to the function pointer variable <code>pFunc</code> as in <code>pFunc = func;</code>.</p>

<p>Notice the syntax used with a function pointer declaration/definition in which parenthesis are used to overcome the natural operator precedence rules.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> *<span class="hljs-title function_">pfunc</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr)</span>;    <span class="hljs-comment">// declares a function that returns int pointer</span>
<span class="hljs-type">int</span> (*pFunc)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr);  <span class="hljs-comment">// declares a function pointer that returns an int</span>
</code></pre>

<p><strong>Several Different Usage Examples</strong></p>

<p>Some examples of usage of a function pointer:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> (*pFunc) (<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr);    <span class="hljs-comment">// declare a simple function pointer variable</span>
<span class="hljs-type">int</span> (*pFunc[<span class="hljs-number">55</span>])(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr); <span class="hljs-comment">// declare an array of 55 function pointers</span>
<span class="hljs-type">int</span> (**pFunc)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr);    <span class="hljs-comment">// declare a pointer to a function pointer variable</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> {</span>                             <span class="hljs-comment">// declare a struct that contains a function pointer</span>
    <span class="hljs-type">int</span> x22;
    <span class="hljs-type">int</span> (*pFunc)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr);
} thing = {<span class="hljs-number">0</span>, func};                 <span class="hljs-comment">// assign values to the struct variable</span>
<span class="hljs-type">char</span> * <span class="hljs-title function_">xF</span> <span class="hljs-params">(<span class="hljs-type">int</span> x, <span class="hljs-type">int</span> (*p)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr))</span>;  <span class="hljs-comment">// declare a function that has a function pointer as an argument</span>
<span class="hljs-type">char</span> * (*pxF) (<span class="hljs-type">int</span> x, <span class="hljs-type">int</span> (*p)(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *pStr));  <span class="hljs-comment">// declare a function pointer that points to a function that has a function pointer as an argument</span>
</code></pre>

<p>You can use variable length parameter lists in the definition of a function pointer.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">sum</span> <span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, ...)</span>;
<span class="hljs-type">int</span> (*psum)(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, ...);
</code></pre>

<p>Or you can not specify a parameter list at all. This can be useful but it eliminates the opportunity for the C compiler to perform checks on the argument list provided. </p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span>  <span class="hljs-title function_">sum</span> <span class="hljs-params">()</span>;      <span class="hljs-comment">// nothing specified in the argument list so could be anything or nothing</span>
<span class="hljs-type">int</span> (*psum)();
<span class="hljs-type">int</span>  <span class="hljs-title function_">sum2</span><span class="hljs-params">(<span class="hljs-type">void</span>)</span>;  <span class="hljs-comment">// void specified in the argument list so no parameters when calling this function</span>
<span class="hljs-type">int</span> (*psum2)(<span class="hljs-type">void</span>);
</code></pre>

<p><strong>C style Casts</strong></p>

<p>You can use C style casts with function pointers. However be aware that a C compiler may be lax about checks or provide warnings rather than errors.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> <span class="hljs-title function_">sum</span> <span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">char</span> *b)</span>;
<span class="hljs-type">int</span> (*psplsum) (<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b);
psplsum = sum;               <span class="hljs-comment">// generates a compiler warning</span>
psplsum = (<span class="hljs-type">int</span> (*)(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)) sum;   <span class="hljs-comment">// no compiler warning, cast to function pointer</span>
psplsum = (<span class="hljs-type">int</span> *(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)) sum;     <span class="hljs-comment">// compiler error of bad cast generated, parenthesis are required.</span>
</code></pre>

<p><strong>Compare Function Pointer to Equality</strong></p>

<p>You can check that a function pointer is equal to a particular function address using an <code>if</code> statement though I am not sure how useful that would be. Other comparison operators would seem to have even less utility.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">func1</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)</span> {
    <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">func2</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, <span class="hljs-type">char</span> *c)</span> {
    <span class="hljs-keyword">return</span> c[<span class="hljs-number">0</span>] + a + b;
}

<span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">func3</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, <span class="hljs-type">char</span> *x)</span> {
    <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-keyword">static</span> <span class="hljs-type">char</span> *<span class="hljs-title function_">func4</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, <span class="hljs-type">char</span> *c, <span class="hljs-type">int</span> (*p)())</span>
{
    <span class="hljs-keyword">if</span> (p == func1) {
        p(a, b);
    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (p == func2) {
        p(a, b, c);      <span class="hljs-comment">// warning C4047: '==': 'int (__cdecl *)()' differs in levels of indirection from 'char *(__cdecl *)(int,int,char *)'</span>
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (p == func3) {
        p(a, b, c);
    }
    <span class="hljs-keyword">return</span> c;
}
</code></pre>

<p><strong>An Array of Function Pointers</strong></p>

<p>And if you want to have an array of function pointers each of the elements of which the argument list has differences then you can define a function pointer with the argument list unspecified (not <code>void</code> which means no arguments but just unspecified) something like the following though you may see warnings from the C compiler. This also works for a function pointer parameter to a function:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span>(*p[])() = {       <span class="hljs-comment">// an array of function pointers</span>
    func1, func2, func3
};
<span class="hljs-type">int</span>(**pp)();          <span class="hljs-comment">// a pointer to a function pointer</span>


p[<span class="hljs-number">0</span>](a, b);
p[<span class="hljs-number">1</span>](a, b, <span class="hljs-number">0</span>);
p[<span class="hljs-number">2</span>](a, b);      <span class="hljs-comment">// oops, left off the last argument but it compiles anyway.</span>

func4(a, b, <span class="hljs-number">0</span>, func1);
func4(a, b, <span class="hljs-number">0</span>, func2);  <span class="hljs-comment">// warning C4047: 'function': 'int (__cdecl *)()' differs in levels of indirection from 'char *(__cdecl *)(int,int,char *)'</span>
func4(a, b, <span class="hljs-number">0</span>, func3);

    <span class="hljs-comment">// iterate over the array elements using an array index</span>
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-keyword">sizeof</span>(p) / <span class="hljs-keyword">sizeof</span>(p[<span class="hljs-number">0</span>]); i++) {
    func4(a, b, <span class="hljs-number">0</span>, p[i]);
}
    <span class="hljs-comment">// iterate over the array elements using a pointer</span>
<span class="hljs-keyword">for</span> (pp = p; pp &lt; p + <span class="hljs-keyword">sizeof</span>(p)/<span class="hljs-keyword">sizeof</span>(p[<span class="hljs-number">0</span>]); pp++) {
    (*pp)(a, b, <span class="hljs-number">0</span>);          <span class="hljs-comment">// pointer to a function pointer so must dereference it.</span>
    func4(a, b, <span class="hljs-number">0</span>, *pp);     <span class="hljs-comment">// pointer to a function pointer so must dereference it.</span>
}
</code></pre>

<p><strong>C style <code>namespace</code> Using Global <code>struct</code> with Function Pointers</strong></p>

<p>You can use the <code>static</code> keyword to specify a function whose name is file scope and then assign this to a global variable as a way of providing something similar to the <code>namespace</code> functionality of C++.</p>

<p>In a header file define a struct that will be our namespace along with a global variable that uses it.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> {</span>
   <span class="hljs-type">int</span> (*func1) (<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b);             <span class="hljs-comment">// pointer to function that returns an int</span>
   <span class="hljs-type">char</span> *(*func2) (<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, <span class="hljs-type">char</span> *c);  <span class="hljs-comment">// pointer to function that returns a pointer</span>
} FuncThings;

<span class="hljs-keyword">extern</span> <span class="hljs-keyword">const</span> FuncThings FuncThingsGlobal;
</code></pre>

<p>Then in the C source file:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">"header.h"</span></span>

<span class="hljs-comment">// the function names used with these static functions do not need to be the</span>
<span class="hljs-comment">// same as the struct member names. It's just helpful if they are when trying</span>
<span class="hljs-comment">// to search for them.</span>
<span class="hljs-comment">// the static keyword ensures these names are file scope only and not visible</span>
<span class="hljs-comment">// outside of the file.</span>
<span class="hljs-keyword">static</span> <span class="hljs-type">int</span> <span class="hljs-title function_">func1</span> <span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)</span>
{
    <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-keyword">static</span> <span class="hljs-type">char</span> *<span class="hljs-title function_">func2</span> <span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b, <span class="hljs-type">char</span> *c)</span>
{
    c[<span class="hljs-number">0</span>] = a % <span class="hljs-number">100</span>; c[<span class="hljs-number">1</span>] = b % <span class="hljs-number">50</span>;
    <span class="hljs-keyword">return</span> c;
}

<span class="hljs-keyword">const</span> FuncThings FuncThingsGlobal = {func1, func2};
</code></pre>

<p>This would then be used by specifying the complete name of global struct variable and member name to access the function. The <code>const</code> modifier is used on the global so that it can not be changed by accident.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">int</span> abcd = FuncThingsGlobal.func1 (a, b);
</code></pre>

<p><strong>Application Areas of Function Pointers</strong></p>

<p>A DLL library component could do something similar to the C style <code>namespace</code> approach in which a particular library interface is requested from a factory method in a library interface which supports the creation of a <code>struct</code> containing function pointers.. This library interface loads the requested DLL version, creates a struct with the necessary function pointers, and then returns the struct to the requesting caller for use.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-keyword">typedef</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> {</span>
    HMODULE  hModule;
    <span class="hljs-type">int</span> (*Func1)();
    <span class="hljs-type">int</span> (*Func2)();
    <span class="hljs-type">int</span>(*Func3)(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b);
} LibraryFuncStruct;

<span class="hljs-type">int</span>  LoadLibraryFunc LPCTSTR  dllFileName, LibraryFuncStruct *pStruct)
{
    <span class="hljs-type">int</span>  retStatus = <span class="hljs-number">0</span>;   <span class="hljs-comment">// default is an error detected</span>

    pStruct-&gt;hModule = LoadLibrary (dllFileName);
    <span class="hljs-keyword">if</span> (pStruct-&gt;hModule) {
        pStruct-&gt;Func1 = (<span class="hljs-type">int</span> (*)()) GetProcAddress (pStruct-&gt;hModule, <span class="hljs-string">"Func1"</span>);
        pStruct-&gt;Func2 = (<span class="hljs-type">int</span> (*)()) GetProcAddress (pStruct-&gt;hModule, <span class="hljs-string">"Func2"</span>);
        pStruct-&gt;Func3 = (<span class="hljs-type">int</span> (*)(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)) GetProcAddress(pStruct-&gt;hModule, <span class="hljs-string">"Func3"</span>);
        retStatus = <span class="hljs-number">1</span>;
    }

    <span class="hljs-keyword">return</span> retStatus;
}

<span class="hljs-type">void</span> <span class="hljs-title function_">FreeLibraryFunc</span> <span class="hljs-params">(LibraryFuncStruct *pStruct)</span>
{
    <span class="hljs-keyword">if</span> (pStruct-&gt;hModule) FreeLibrary (pStruct-&gt;hModule);
    pStruct-&gt;hModule = <span class="hljs-number">0</span>;
}
</code></pre>

<p>and this could be used as in:</p>

<pre class="lang-c s-code-block"><code class="hljs language-c">LibraryFuncStruct myLib = {<span class="hljs-number">0</span>};
LoadLibraryFunc (<span class="hljs-string">L"library.dll"</span>, &amp;myLib);
<span class="hljs-comment">//  ....</span>
myLib.Func1();
<span class="hljs-comment">//  ....</span>
FreeLibraryFunc (&amp;myLib);
</code></pre>

<p>The same approach can be used to define an abstract hardware layer for code that uses a particular model of the underlying hardware. Function pointers are filled in with hardware specific functions by a factory to provide the hardware specific functionality that implements functions specified in the abstract hardware model. This can be used to provide an abstract hardware layer used by software which calls a factory function in order to get the specific hardware function interface then uses the function pointers provided to perform actions for the underlying hardware without needing to know implementation details about the specific target.</p>

<p><strong>Function Pointers to create Delegates, Handlers, and Callbacks</strong></p>

<p>You can use function pointers as a way to delegate some task or functionality. The classic example in C is the comparison delegate function pointer used with the Standard C library functions <code>qsort()</code> and <code>bsearch()</code> to provide the collation order for sorting a list of items or performing a binary search over a sorted list of items. The comparison function delegate specifies the collation algorithm used in the sort or the binary search.</p>

<p>Another use is similar to applying an algorithm to a C++ Standard Template Library container.</p>

<pre class="lang-c s-code-block"><code class="hljs language-c"><span class="hljs-type">void</span> * <span class="hljs-title function_">ApplyAlgorithm</span> <span class="hljs-params">(<span class="hljs-type">void</span> *pArray, <span class="hljs-type">size_t</span> sizeItem, <span class="hljs-type">size_t</span> nItems, <span class="hljs-type">int</span> (*p)(<span class="hljs-type">void</span> *))</span> {
    <span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> *pList = pArray;
    <span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> *pListEnd = pList + nItems * sizeItem;
    <span class="hljs-keyword">for</span> ( ; pList &lt; pListEnd; pList += sizeItem) {
        p (pList);
    }

    <span class="hljs-keyword">return</span> pArray;
}

<span class="hljs-type">int</span> <span class="hljs-title function_">pIncrement</span><span class="hljs-params">(<span class="hljs-type">int</span> *pI)</span> {
    (*pI)++;

    <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
}

<span class="hljs-type">void</span> * <span class="hljs-title function_">ApplyFold</span><span class="hljs-params">(<span class="hljs-type">void</span> *pArray, <span class="hljs-type">size_t</span> sizeItem, <span class="hljs-type">size_t</span> nItems, <span class="hljs-type">void</span> * pResult, <span class="hljs-type">int</span>(*p)(<span class="hljs-type">void</span> *, <span class="hljs-type">void</span> *))</span> {
    <span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> *pList = pArray;
    <span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> *pListEnd = pList + nItems * sizeItem;
    <span class="hljs-keyword">for</span> (; pList &lt; pListEnd; pList += sizeItem) {
        p(pList, pResult);
    }

    <span class="hljs-keyword">return</span> pArray;
}

<span class="hljs-type">int</span> <span class="hljs-title function_">pSummation</span><span class="hljs-params">(<span class="hljs-type">int</span> *pI, <span class="hljs-type">int</span> *pSum)</span> {
    (*pSum) += *pI;

    <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
}

<span class="hljs-comment">// source code and then lets use our function.</span>
<span class="hljs-type">int</span> intList[<span class="hljs-number">30</span>] = { <span class="hljs-number">0</span> }, iSum = <span class="hljs-number">0</span>;

ApplyAlgorithm(intList, <span class="hljs-keyword">sizeof</span>(<span class="hljs-type">int</span>), <span class="hljs-keyword">sizeof</span>(intList) / <span class="hljs-keyword">sizeof</span>(intList[<span class="hljs-number">0</span>]), pIncrement);
ApplyFold(intList, <span class="hljs-keyword">sizeof</span>(<span class="hljs-type">int</span>), <span class="hljs-keyword">sizeof</span>(intList) / <span class="hljs-keyword">sizeof</span>(intList[<span class="hljs-number">0</span>]), &amp;iSum, pSummation);
</code></pre>

<p>Another example is with GUI source code in which a handler for a particular event is registered by providing a function pointer which is actually called when the event happens. The Microsoft MFC framework with its message maps uses something similar to handle Windows messages that are delivered to a window or thread.</p>

<p>Asynchronous functions that require a callback are similar to an event handler. The user of the asynchronous function calls the asynchronous function to start some action and provides a function pointer which the asynchronous function will call once the action is complete. In this case the event is the asynchronous function completing its task.</p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2018-08-20T05:47:15"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="51924748">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/51924748" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-10" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-10"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 4.0">CC BY-SA 4.0</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/51924748/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-51924748" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-aaps057f">
                    Follow
                </button><div id="--stacks-s-tooltip-aaps057f" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        answered <a href="https://stackoverflow.com/posts/51924748/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title="2018-08-20 05:47:15Z" class="relativetime">Aug 20, 2018 at 5:47</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of Aug 20, 2018 at 5:47. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-51924748" href="https://stackoverflow.com/posts/51924748/revisions" title="show revision history for this post">
        Richard Chambers
        </a>
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount">0</span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-51924748" class="comments js-comments-container bt bc-black-075 mt12  dno" data-post-id="51924748" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

            </ul>
	    </div>

        <div id="comments-link-51924748" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>
                                          
<a name="843373"></a>
<div id="answer-843373" class="answer js-answer" data-answerid="843373" data-score="1" data-position-on-page="11" data-highest-scored="0" data-question-has-accepted-highest-score="1" data-ivc="/answers/843373/ivc/9f35?sort=4&amp;shared=0&amp;position=11&amp;accepted=0&amp;highest=0" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer">
    <div class="post-layout">
        <div class="votecell post-layout--left">
            <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="843373">
        <button class="js-vote-up-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-o8szfcjy">
            <svg aria-hidden="true" class="svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 25h32L18 9 2 25Z"></path></svg>
        </button><div id="--stacks-s-tooltip-o8szfcjy" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
        <div class="js-vote-count flex--item d-flex fd-column ai-center fc-black-500 fs-title" itemprop="upvoteCount" data-value="1">
            1
        </div>
        <button class="js-vote-down-btn flex--item s-btn s-btn__unset c-pointer " data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" data-unselected-classes="" aria-describedby="--stacks-s-tooltip-zsqom0av">
            <svg aria-hidden="true" class="svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 11h32L18 27 2 11Z"></path></svg>
        </button><div id="--stacks-s-tooltip-zsqom0av" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>

    
            <div class="js-accepted-answer-indicator flex--item fc-green-500 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
                <div class="ta-center">
                    <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"></path></svg>
                </div>
            </div>

    
        <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="https://stackoverflow.com/posts/843373/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-z9rml42e"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"></path></svg></a><div id="--stacks-s-tooltip-z9rml42e" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>

</div>

        </div>

        

<div class="answercell post-layout--right">
    
    <div class="s-prose js-post-body" itemprop="text">
<p>Since function pointers are often typed callbacks, you might want to have a look at <a href="http://ccan.ozlabs.org/info/typesafe_cb.html" rel="nofollow noreferrer">type safe callbacks</a>. The same applies to entry points, etc of functions that are not callbacks.</p>

<p>C is quite fickle and forgiving at the same time :)</p>
    </div>
    <div class="mt24">
        <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
            <time itemprop="dateCreated" datetime="2009-05-09T13:56:12"></time>
            <div class="flex--item mr16" style="flex: 1 1 100px;">
                


<div class="js-post-menu pt2" data-post-id="843373">
    <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">

            <div class="flex--item">
                <a href="https://stackoverflow.com/a/843373" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet s-popover" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start" aria-controls="se-share-sheet-11" data-action=" s-popover#toggle se-share-sheet#preventNavigation s-popover:show-&gt;se-share-sheet#willShow s-popover:shown-&gt;se-share-sheet#didShow">Share</a><div class="s-popover z-dropdown s-anchors s-anchors__default" style="width: unset; max-width: 28em;" id="se-share-sheet-11"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle"></span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between ai-center mbn4"><button class="js-copy-link-btn s-btn s-btn__link js-gps-track" data-gps-track="">Copy link</button><a href="https://creativecommons.org/licenses/by-sa/2.5/" rel="license" class="js-license s-block-link w-auto" target="_blank" title="The current license for this post: CC BY-SA 2.5">CC BY-SA 2.5</a><div class="js-social-container d-none"></div></div></div>
            </div>


                    <div class="flex--item">
                        <a href="https://stackoverflow.com/posts/843373/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
                    </div>

            <div class="flex--item">
                <button type="button" id="btnFollowPost-843373" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-s1fc24jl">
                    Follow
                </button><div id="--stacks-s-tooltip-s1fc24jl" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
            </div>






    </div>
    <div class="js-menu-popup-container"></div>
</div>
            </div>
            <div class="post-signature flex--item fl0">
<div class="user-info ">
    <div class="user-action-time">
        answered <a href="https://stackoverflow.com/posts/843373/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title="2009-05-09 13:56:12Z" class="relativetime">May 9, 2009 at 13:56</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        
        <div class="-flair">
            
        </div>
    </div>
</div>
            </div>


            <div class="post-signature flex--item fl0">
                <div class="user-info">
    <div class="user-details">
        <span class="community-wiki" title="This post is community owned as of May 9, 2009 at 13:56. Votes do not generate reputation, and it can be edited by users with 100 rep">
            community wiki
        </span>
    </div><br>
    <div class="user-details">
        <a id="history-843373" href="https://stackoverflow.com/posts/843373/revisions" title="show revision history for this post">
        Tim Post
        </a>
    </div>
</div>

            </div>
        </div>
        
    
    </div>
    
</div>




            <span class="d-none" itemprop="commentCount"></span> 
    <div class="post-layout--right js-post-comments-component">
        <div id="comments-843373" class="comments js-comments-container bt bc-black-075 mt12  dno" data-post-id="843373" data-min-length="15">
            <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

            </ul>
	    </div>

        <div id="comments-link-843373" data-rep="50" data-anon="true">
                    <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" role="button">Add a comment</a>
                <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" onclick="" role="button"></a>
        </div>         
    </div>
    </div>
</div>

                                    <aside class="s-notice s-notice__info post-notice js-post-notice mb16" role="status">
        <div class="d-flex fd-column fw-nowrap">
            <div class="d-flex fw-nowrap">
                    <div class="flex--item mr8">
                        <svg aria-hidden="true" class="svg-icon iconFire" width="18" height="18" viewBox="0 0 18 18"><path opacity=".6" d="M13.18 9c-.8.33-1.46.6-1.97 1.3A9.21 9.21 0 0 0 10 13.89a10 10 0 0 0 1.32-.8 2.53 2.53 0 0 1-.63 2.91h.78a3 3 0 0 0 1.66-.5 4.15 4.15 0 0 0 1.26-1.61c.4-.96.47-1.7.55-2.73.05-1.24-.1-2.49-.46-3.68a2 2 0 0 1-.4.91 2.1 2.1 0 0 1-.9.62Z" fill="#FF6700"></path><path d="M10.4 12.11a7.1 7.1 0 0 1 .78-1.76c.3-.47.81-.8 1.37-1.08 0 0-.05-3.27-1.55-5.27-1.5-2-3.37-2.75-4.95-2.61 0 0 4.19 2.94 1.18 5.67-2.14 1.92-3.64 3.81-3.1 5.94a4.14 4.14 0 0 0 3.1 3 4.05 4.05 0 0 1 1.08-3.89C9.42 10.92 8 9.79 8 9.79c.67.02 1.3.28 1.81.72a2 2 0 0 1 .58 1.6Z" fill="#EF2E2E"></path></svg>
                    </div>
                <div class="flex--item wmn0 fl1 lh-lg">
                    <div class="flex--item fl1 lh-lg">
                        <b><a href="https://stackoverflow.com/help/privileges/protect-questions">Highly active question</a></b>. Earn 10 reputation (not counting the <a href="https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work">association bonus</a>) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.
                        
                    </div>
                </div>
            </div>
        </div>
</aside>



                            <h2 class="bottom-notice" data-loc="1">
Not the answer you're looking for? Browse other questions tagged <a href="https://stackoverflow.com/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a> <a href="https://stackoverflow.com/questions/tagged/function-pointers" class="post-tag" title="show questions tagged &#39;function-pointers&#39;" rel="tag">function-pointers</a>  or <a href="https://stackoverflow.com/questions/ask">ask your own question</a>.                            </h2>
                </div>
            </div>
            <div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar">
                    

                
<div class="s-sidebarwidget s-sidebarwidget__yellow s-anchors s-anchors__grayscale mb16" data-tracker="cb=1">
    <ul class="d-block p0 m0">
                    <div class="s-sidebarwidget--header s-sidebarwidget__small-bold-text fc-light d:fc-black-900 bb bbw1">
                        The Overflow Blog
                    </div>
        <li class="s-sidebarwidget--item d-flex px16">
            <div class="flex--item1 fl-shrink0">
<svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>            </div>
            <div class="flex--item wmn0 ow-break-word">
                <a href="https://stackoverflow.blog/2022/03/23/getting-through-a-soc-2-audit-with-your-nerves-intact/?cb=1" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;The Overflow Blog&quot;,&quot;https://stackoverflow.blog/2022/03/23/getting-through-a-soc-2-audit-with-your-nerves-intact/&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 0 })">Getting through a SOC 2 audit with your nerves intact (Ep. 426)</a>
            </div>
        </li>
        <li class="s-sidebarwidget--item d-flex px16">
            <div class="flex--item1 fl-shrink0">
<svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0ZM2 10.12l6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"></path></svg>            </div>
            <div class="flex--item wmn0 ow-break-word">
                <a href="https://stackoverflow.blog/2022/03/24/new-data-top-movies-and-coding-music-according-to-developers/?cb=1" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;The Overflow Blog&quot;,&quot;https://stackoverflow.blog/2022/03/24/new-data-top-movies-and-coding-music-according-to-developers/&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 1 })">New data: Top movies and coding music according to developers</a>
            </div>
        </li>
                    <div class="s-sidebarwidget--header s-sidebarwidget__small-bold-text fc-light d:fc-black-900 bb bbw1">
                        Featured on Meta
                    </div>
        <li class="s-sidebarwidget--item d-flex px16">
            <div class="flex--item1 fl-shrink0">
<div class="favicon favicon-stackexchangemeta" title="Meta Stack Exchange"></div>            </div>
            <div class="flex--item wmn0 ow-break-word">
                <a href="https://meta.stackexchange.com/questions/376743/stack-exchange-qa-access-will-not-be-restricted-in-russia?cb=1" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackexchange.com/questions/376743/stack-exchange-qa-access-will-not-be-restricted-in-russia&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 3, position: 2 })">Stack Exchange Q&amp;A access will not be restricted in Russia</a>
            </div>
        </li>
        <li class="s-sidebarwidget--item d-flex px16">
            <div class="flex--item1 fl-shrink0">
<div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>            </div>
            <div class="flex--item wmn0 ow-break-word">
                <a href="https://meta.stackoverflow.com/questions/416652/new-user-experience-deep-dive-into-our-research-on-the-staging-ground-how-do?cb=1" class="js-gps-track" title="New User Experience: Deep Dive into our Research on the Staging Ground – How do you feel about review badges &amp; opt-in settings for the Staging Ground?" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackoverflow.com/questions/416652/new-user-experience-deep-dive-into-our-research-on-the-staging-ground-how-do&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 3 })">New User Experience: Deep Dive into our Research on the Staging Ground – How...</a>
            </div>
        </li>
        <li class="s-sidebarwidget--item d-flex px16">
            <div class="flex--item1 fl-shrink0">
<div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>            </div>
            <div class="flex--item wmn0 ow-break-word">
                <a href="https://meta.stackoverflow.com/questions/416735/ask-wizard-for-new-users-feature-test-is-now-live?cb=1" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackoverflow.com/questions/416735/ask-wizard-for-new-users-feature-test-is-now-live&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 4 })">Ask Wizard for New Users Feature Test is now Live</a>
            </div>
        </li>
    </ul>
</div>


<div class="js-zone-container zone-container-sidebar">
    <div id="dfp-tsb" class="everyonelovesstackoverflow everyoneloves__top-sidebar" data-dfp-zone="true" style="min-height: auto; height: auto; display: none;" data-google-query-id="CKuLj62_6PYCFeSAmwodzCQAPQ" data-clc-ready="true"><div id="google_ads_iframe_/248424177/stackoverflow.com/sb/question-pages_0__container__" style="border: 0pt none; width: 300px; height: auto; min-height: auto; display: none;"></div></div>
    <div class="js-report-ad-button-container " style="width: 300px"></div>
</div>
<div class="js-zone-container zone-container-sidebar">
    <div id="dfp-msb" class="everyonelovesstackoverflow everyoneloves__mid-sidebar" data-dfp-zone="true" style="min-height: auto; height: auto; display: none;" data-clc-stalled="true" data-google-query-id="CIyEj62_6PYCFUagmgod8QAI8A"><div id="google_ads_iframe_/248424177/stackoverflow.com/msb/question-pages_0__container__" style="border: 0pt none; width: 300px; height: 0px;"></div></div>
    <div class="js-report-ad-button-container " style="width: 300px"></div>
</div>
<div id="hireme"></div>                    <div class="module sidebar-linked">
	<h4 id="h-linked">Linked</h4>
	<div class="linked" data-tracker="lq=1">
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 21411113, position: 0 })">
				<a href="https://stackoverflow.com/q/21411113?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">5</div>
				</a>
				<a href="https://stackoverflow.com/questions/21411113/what-does-void-routinevoid-mean-in-c?noredirect=1&amp;lq=1" class="question-hyperlink">What does void *(*routine)(void *) mean in C?</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 39255938, position: 1 })">
				<a href="https://stackoverflow.com/q/39255938?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">3</div>
				</a>
				<a href="https://stackoverflow.com/questions/39255938/c-pass-pointer-as-argument-in-function?noredirect=1&amp;lq=1" class="question-hyperlink">C pass pointer as argument in function</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 15643054, position: 2 })">
				<a href="https://stackoverflow.com/q/15643054?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">6</div>
				</a>
				<a href="https://stackoverflow.com/questions/15643054/passing-function-pointers-as-arguments?noredirect=1&amp;lq=1" class="question-hyperlink">Passing function pointers as arguments</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 38846296, position: 3 })">
				<a href="https://stackoverflow.com/q/38846296?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">3</div>
				</a>
				<a href="https://stackoverflow.com/questions/38846296/what-does-an-asterisk-in-empty-parentheses-mean?noredirect=1&amp;lq=1" class="question-hyperlink">What does an asterisk in empty parentheses mean?</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 47422351, position: 4 })">
				<a href="https://stackoverflow.com/q/47422351?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">2</div>
				</a>
				<a href="https://stackoverflow.com/questions/47422351/what-does-void-void-and-int-int-mean-in-c?noredirect=1&amp;lq=1" class="question-hyperlink">what does void(*) void and int(*) int mean in C?</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 17678738, position: 5 })">
				<a href="https://stackoverflow.com/q/17678738?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">0</div>
				</a>
				<a href="https://stackoverflow.com/questions/17678738/function-pointers-error-in-c?noredirect=1&amp;lq=1" class="question-hyperlink">Function Pointers Error In C</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 54549121, position: 6 })">
				<a href="https://stackoverflow.com/q/54549121?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">0</div>
				</a>
				<a href="https://stackoverflow.com/questions/54549121/what-is-int-fp?noredirect=1&amp;lq=1" class="question-hyperlink">What is int (*fp)()</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 65305737, position: 7 })">
				<a href="https://stackoverflow.com/q/65305737?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes  default">2</div>
				</a>
				<a href="https://stackoverflow.com/questions/65305737/what-is-foo?noredirect=1&amp;lq=1" class="question-hyperlink">What is foo*(*)?</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 16580411, position: 8 })">
				<a href="https://stackoverflow.com/q/16580411?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes answered-accepted default">3</div>
				</a>
				<a href="https://stackoverflow.com/questions/16580411/for-function-pointer-fptr-why-is-value-of-fptr-and-fptr-samewhat-fptr-eve?noredirect=1&amp;lq=1" class="question-hyperlink">For function pointer "fptr",why is value of "fptr" and *fptr same?What *fptr even mean?I only knew (*fptr)() or fptr()</a>
			</div>
            <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 840501, target_question_id: 31910567, position: 9 })">
				<a href="https://stackoverflow.com/q/31910567?lq=1" title="Question score (upvotes - downvotes)">
					<div class="answer-votes  default">4</div>
				</a>
				<a href="https://stackoverflow.com/questions/31910567/understanding-function-pointers-and-their-syntax?noredirect=1&amp;lq=1" class="question-hyperlink">Understanding function pointers and their syntax</a>
			</div>
		    <div class="spacer more ml32 pl16 pt8">
                <a href="https://stackoverflow.com/questions/linked/840501?lq=1">See more linked questions</a>
            </div>
	</div>
</div>


                    <div class="module sidebar-related">
                        <h4 id="h-related">Related</h4>
                        <div class="related js-gps-related-questions" data-tracker="rq=1">
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/37538?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted extra-large">1252</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/37538/how-do-i-determine-the-size-of-my-array-in-c?rq=1" class="question-hyperlink">How do I determine the size of my array in C?</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/47981?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted extra-large">2936</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit?rq=1" class="question-hyperlink">How do you set, clear, and toggle a single bit?</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/252748?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes large">191</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/252748/how-can-i-use-an-array-of-function-pointers?rq=1" class="question-hyperlink">How can I use an array of function pointers?</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/306017?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted default">6</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/306017/using-far-function-pointers?rq=1" class="question-hyperlink">Using far function pointers</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/654754?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted large">608</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/654754/what-really-happens-when-you-dont-free-after-malloc-before-program-termination?rq=1" class="question-hyperlink">What REALLY happens when you don't free after malloc before program termination?</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/1591361?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes large">261</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/1591361/understanding-typedefs-for-function-pointers-in-c?rq=1" class="question-hyperlink">Understanding typedefs for function pointers in C</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/1711631?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted extra-large">3192</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite?rq=1" class="question-hyperlink">Improve INSERT-per-second performance of SQLite</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/3789340?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted large">365</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/3789340/combining-c-and-c-how-does-ifdef-cplusplus-work?rq=1" class="question-hyperlink">Combining C++ and C - how does #ifdef __cplusplus work?</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/13404007?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted default">19</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/13404007/helping-the-compiler-optimize-function-pointers?rq=1" class="question-hyperlink">Helping the compiler optimize function pointers</a>
                                </div>
                                <div class="spacer js-gps-track">
                                    <a href="https://stackoverflow.com/q/66970449?rq=1" title="Question score (upvotes - downvotes)">
                                        <div class="answer-votes answered-accepted default">2</div>
                                    </a>
                                    <a href="https://stackoverflow.com/questions/66970449/how-to-make-a-function-which-returns-a-function-pointer-in-an-array-of-function?rq=1" class="question-hyperlink">How to make a function which returns a function pointer in an array of function pointers</a>
                                </div>
                        </div>
                    </div>

                <div id="hot-network-questions" class="module tex2jax_ignore">
    <h4>
        <a href="https://stackexchange.com/questions?tab=hot" class="js-gps-track s-link s-link__inherit" data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">
            Hot Network Questions
        </a>
    </h4>
    <ul>
            <li>
                <div class="favicon favicon-codereview" title="Code Review Stack Exchange"></div><a href="https://codereview.stackexchange.com/questions/275268/automate-the-boring-stuff-ch-7-password-strength-test" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:196 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Automate the Boring Stuff CH 7: password strength test
                </a>

            </li>
            <li>
                <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="https://rpg.stackexchange.com/questions/197192/is-it-mathematically-better-to-roll-one-attack-or-two-with-disadvantage" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is it mathematically better to roll one attack or two with disadvantage?
                </a>

            </li>
            <li>
                <div class="favicon favicon-astronomy" title="Astronomy Stack Exchange"></div><a href="https://astronomy.stackexchange.com/questions/48941/it-takes-light-roughly-8-minutes-to-travel-to-earth-from-the-sun-but-based-on-w" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:514 }); posts_hot_network.click({ item_type:2, location:11 })">
                    It takes light roughly 8 minutes to travel to Earth from the Sun, but based on which perspective?
                </a>

            </li>
            <li>
                <div class="favicon favicon-academia" title="Academia Stack Exchange"></div><a href="https://academia.stackexchange.com/questions/183609/why-do-masters-phd-when-you-can-just-do-a-phd-and-then-do-a-postdoc" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:415 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why do Masters + PhD, when you can just do a PhD and then do a PostDoc?
                </a>

            </li>
            <li>
                <div class="favicon favicon-diy" title="Home Improvement Stack Exchange"></div><a href="https://diy.stackexchange.com/questions/246743/using-old-vent-pipe-as-tv-antenna" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:73 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Using old vent pipe as TV antenna
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-aviation" title="Aviation Stack Exchange"></div><a href="https://aviation.stackexchange.com/questions/92430/why-is-tso-named-so-where-is-the-order-part-in-this-isnt-it-just-a-standard" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:528 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why is TSO named so? Where is the 'order' part in this? Isn't it just a standard?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-apple" title="Ask Different"></div><a href="https://apple.stackexchange.com/questions/438978/how-to-reach-the-etc-folder-from-cd-macintosh-hd" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:118 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How to reach the /etc folder from cd /Macintosh/ HD?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-worldbuilding" title="Worldbuilding Stack Exchange"></div><a href="https://worldbuilding.stackexchange.com/questions/227337/how-why-is-it-even-possible-to-have-a-self-contained-civil-war-war-the-modern" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:579 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How/ Why/ Is it even possible to have a self contained civil war/ war the modern/ future era?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-travel" title="Travel Stack Exchange"></div><a href="https://travel.stackexchange.com/questions/172816/european-rail-pass-for-seniors" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:273 }); posts_hot_network.click({ item_type:2, location:11 })">
                    European rail pass for seniors
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-writing" title="Writing Stack Exchange"></div><a href="https://writing.stackexchange.com/questions/61693/do-i-need-copyright-permission-to-rewrite-an-old-classic" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:166 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Do I need copyright permission to rewrite an old classic?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="https://rpg.stackexchange.com/questions/197173/how-can-i-stop-forgetting-to-use-my-abilities" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How can I stop forgetting to use my abilities?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-latin" title="Latin Language Stack Exchange"></div><a href="https://latin.stackexchange.com/questions/17969/is-the-use-of-copia-verae-correct" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:644 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is the use of "copia verae" correct?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-cstheory" title="Theoretical Computer Science Stack Exchange"></div><a href="https://cstheory.stackexchange.com/questions/51261/nontrivial-algorithms-for-coloring-parameterized-by-pathwidth" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:114 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Nontrivial Algorithms for Coloring (Parameterized by Pathwidth)
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-scifi" title="Science Fiction &amp; Fantasy Stack Exchange"></div><a href="https://scifi.stackexchange.com/questions/261696/lifespan-of-rachael-and-other-replicants" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Lifespan of Rachael and other Replicants?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-retrocomputing" title="Retrocomputing Stack Exchange"></div><a href="https://retrocomputing.stackexchange.com/questions/24167/why-is-slash-so-commonly-used-in-old-systems-abbreviations" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:648 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why is slash so commonly used in old systems' abbreviations?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-astronomy" title="Astronomy Stack Exchange"></div><a href="https://astronomy.stackexchange.com/questions/48945/why-on-mars-are-the-seasons-are-strongly-amplified-in-the-southern-hemisphere" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:514 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why on Mars are the seasons are "strongly amplified" in the southern hemisphere and masked in the northern hemisphere?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-linguistics" title="Linguistics Stack Exchange"></div><a href="https://linguistics.stackexchange.com/questions/44149/how-similar-are-ukrainian-and-russian" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:312 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How similar are Ukrainian and Russian?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-money" title="Personal Finance &amp; Money Stack Exchange"></div><a href="https://money.stackexchange.com/questions/150072/how-should-i-chose-a-financial-planner-advisor" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:93 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How should I chose a Financial Planner/Advisor?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="https://politics.stackexchange.com/questions/72125/why-is-alcohol-restricted-to-21-in-the-us-while-other-potentially-harmful-thing" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:475 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why is alcohol restricted to 21 in the US, while other potentially harmful things are allowed at 18?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-codegolf" title="Code Golf Stack Exchange"></div><a href="https://codegolf.stackexchange.com/questions/245625/remove-unmatched-brackets" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:200 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Remove unmatched brackets
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/638600/fit-equation-with-cases-in-page-width-using-resizebox" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Fit equation with \cases in page width using \resizebox
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-physics" title="Physics Stack Exchange"></div><a href="https://physics.stackexchange.com/questions/700678/why-didnt-the-klein-gordon-equation-suggest-antimatter-like-the-dirac-equation" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:151 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why didn't the Klein-Gordon equation suggest antimatter like the Dirac equation did?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="https://security.stackexchange.com/questions/260722/does-open-source-protestware-represent-a-security-risk" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:162 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Does open source "protestware" represent a security risk?
                </a>

            </li>
            <li class="js-hidden" style="">
                <div class="favicon favicon-music" title="Music: Practice &amp; Theory Stack Exchange"></div><a href="https://music.stackexchange.com/questions/122075/historical-origin-of-the-raised-sixth-scale-degree-in-minor" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:240 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Historical origin of the raised sixth scale degree in minor
                </a>

            </li>
    </ul>

        
</div>

                            <div id="feed-link" class="js-feed-link">
        <a href="https://stackoverflow.com/feeds/question/840501" title="Feed of this question and its answers">
            <svg aria-hidden="true" class="fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M1 3c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v12c0 1.09-.91 2-2 2H3c-1.09 0-2-.91-2-2V3Zm14.5 12C15.5 8.1 9.9 2.5 3 2.5V5a10 10 0 0 1 10 10h2.5Zm-5 0A7.5 7.5 0 0 0 3 7.5V10a5 5 0 0 1 5 5h2.5Zm-5 0A2.5 2.5 0 0 0 3 12.5V15h2.5Z"></path></svg>
            Question feed
        </a>
    </div>
    <aside class="s-modal js-feed-link-modal" tabindex="-1" role="dialog" aria-labelledby="feed-modal-title" aria-describedby="feed-modal-description" aria-hidden="true">
        <div class="s-modal--dialog js-modal-dialog wmx4" role="document" data-controller="se-draggable">
            <h1 class="s-modal--header fw-bold js-first-tabbable c-move" id="feed-modal-title" data-se-draggable-target="handle" tabindex="0">
                Subscribe to RSS
            </h1>
            <div class="d-flex gs4 gsy fd-column">
                <div class="flex--item">
                    <label class="d-block s-label c-default" for="feed-url">
                        Question feed
                        <p class="s-description mt2" id="feed-modal-description">To subscribe to this RSS feed, copy and paste this URL into your RSS reader.</p>
                    </label>
                </div>
                <div class="d-flex ps-relative">
                    <input class="s-input" type="text" name="feed-url" id="feed-url" readonly="readonly" value="https://stackoverflow.com/feeds/question/840501">
                    <svg aria-hidden="true" class="s-input-icon fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M1 3c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v12c0 1.09-.91 2-2 2H3c-1.09 0-2-.91-2-2V3Zm14.5 12C15.5 8.1 9.9 2.5 3 2.5V5a10 10 0 0 1 10 10h2.5Zm-5 0A7.5 7.5 0 0 0 3 7.5V10a5 5 0 0 1 5 5h2.5Zm-5 0A2.5 2.5 0 0 0 3 12.5V15h2.5Z"></path></svg>
                </div>
            </div>
            <a class="s-modal--close s-btn s-btn__muted js-modal-close js-last-tabbable" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" aria-label="Close">
                <svg aria-hidden="true" class="svg-icon iconClearSm" width="14" height="14" viewBox="0 0 14 14"><path d="M12 3.41 10.59 2 7 5.59 3.41 2 2 3.41 5.59 7 2 10.59 3.41 12 7 8.41 10.59 12 12 10.59 8.41 7 12 3.41Z"></path></svg>
            </a>
        </div>
    </aside>

            </div>
    </div>
<script>StackExchange.ready(function(){$.get('/posts/840501/ivc/9f35');});</script>
<noscript><div><img src="/posts/840501/ivc/9f35" class="dno" alt="" width="0" height="0"></div></noscript><div style="display:none" id="js-codeblock-lang">lang-c</div></div>


        </div>
    </div>

        
<script>;(()=>{function k(t){var a=e[t];if(void 0!==a)return a.exports;var s=e[t]={exports:{}};return n[t].call(s.exports,s,s.exports,k),s.exports}var n={291:function(Kt,e){var t;!function(e,t){"use strict";"object"==typeof Kt.exports?Kt.exports=e.document?t(e,!0):function(n){if(!n.document)throw new Error("jQuery requires a window with a document");return t(n)}:t(e)}("undefined"==typeof window?this:window,function(Zt,n){"use strict";function i(a,e,t){var n,s,i=(t=t||y).createElement("script");if(i.text=a,e)for(n in h)(s=e[n]||e.getAttribute&&e.getAttribute(n))&&i.setAttribute(n,s);t.head.appendChild(i).parentNode.removeChild(i)}function w(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?c[u.call(t)]||"object":typeof t}function T(a){var o=!!a&&"length"in a&&a.length,s=w(a);return!dn(a)&&!v(a)&&("array"===s||0===o||"number"==typeof o&&0<o&&o-1 in a)}function S(n,e){return n.nodeName&&n.nodeName.toLowerCase()===e.toLowerCase()}function r(o,s,i){return dn(s)?ln.grep(o,function(t,e){return!!s.call(t,e,t)!==i}):s.nodeType?ln.grep(o,function(t){return t===s!==i}):"string"==typeof s?ln.filter(s,o,i):ln.grep(o,function(t){return-1<a.call(s,t)!==i})}function D(n,e){for(;(n=n[e])&&1!==n.nodeType;);return n}function q(t){return t}function I(t){throw t}function _(a,e,t,n){var o;try{a&&dn(o=a.promise)?o.call(a).done(e).fail(t):a&&dn(o=a.then)?o.call(a,e,t):e.apply(void 0,[a].slice(n))}catch(n){t.apply(void 0,[n])}}function W(){y.removeEventListener("DOMContentLoaded",W),Zt.removeEventListener("load",W),ln.ready()}function F(n,e){return e.toUpperCase()}function z(t){return t.replace(R,"ms-").replace(X,F)}function Y(){this.expando=ln.expando+Y.uid++}function G(a,e,t){var n;if(void 0===t&&1===a.nodeType)if(n="data-"+e.replace(K,"-$&").toLowerCase(),"string"==typeof(t=a.getAttribute(n))){try{t=function(t){return"true"===t||"false"!==t&&("null"===t?null:t===+t+""?+t:Q.test(t)?JSON.parse(t):t)}(t)}catch(t){}V.set(a,e,t)}else t=void 0;return t}function J(d,e,t,n){var r,i,o=20,a=n?function(){return n.cur()}:function(){return ln.css(d,e,"")},s=a(),p=t&&t[3]||(ln.cssNumber[e]?"":"px"),l=d.nodeType&&(ln.cssNumber[e]||"px"!==p&&+s)&&ee.exec(ln.css(d,e));if(l&&l[3]!==p){for(s/=2,p=p||l[3],l=+s||1;o--;)ln.style(d,e,l+p),0>=(1-i)*(1-(i=a()/s||.5))&&(o=0),l/=i;l*=2,ln.style(d,e,l+p),t=t||[]}return t&&(l=+l||+s||0,r=t[1]?l+(t[1]+1)*t[2]:+t[2],n&&(n.unit=p,n.start=l,n.end=r)),r}function ne(a){var e,t=a.ownerDocument,n=a.nodeName,o=re[n];return o||(e=t.body.appendChild(t.createElement(n)),o=ln.css(e,"display"),e.parentNode.removeChild(e),"none"===o&&(o="block"),re[n]=o,o)}function de(s,e){for(var t,n,r=[],i=0,o=s.length;i<o;i++)(n=s[i]).style&&(t=n.style.display,e?("none"===t&&(r[i]=U.get(n,"display")||null,r[i]||(n.style.display="")),""===n.style.display&&ie(n)&&(r[i]=ne(n))):"none"!==t&&(r[i]="none",U.set(n,"display",t)));for(i=0;i<o;i++)null!=r[i]&&(s[i].style.display=r[i]);return s}function pe(a,e){var t;return t=void 0===a.getElementsByTagName?void 0===a.querySelectorAll?[]:a.querySelectorAll(e||"*"):a.getElementsByTagName(e||"*"),void 0===e||e&&S(a,e)?ln.merge([a],t):t}function ce(a,e){for(var o=0,n=a.length;o<n;o++)U.set(a[o],"globalEval",!e||U.get(e[o],"globalEval"))}function xe(g,e,t,n,r){for(var i,o,a,s,u,l,c=e.createDocumentFragment(),f=[],d=0,p=g.length;d<p;d++)if((i=g[d])||0===i)if("object"===w(i))ln.merge(f,i.nodeType?[i]:i);else if(ye.test(i)){for(o=o||c.appendChild(e.createElement("div")),a=(ge.exec(i)||["",""])[1].toLowerCase(),s=me[a]||me._default,o.innerHTML=s[1]+ln.htmlPrefilter(i)+s[2],l=s[0];l--;)o=o.lastChild;ln.merge(f,o.childNodes),(o=c.firstChild).textContent=""}else f.push(e.createTextNode(i));for(c.textContent="",d=0;i=f[d++];)if(n&&-1<ln.inArray(i,n))r&&r.push(i);else if(u=ae(i),o=pe(c.appendChild(i),"script"),u&&ce(o),t)for(l=0;i=o[l++];)fe.test(i.type||"")&&t.push(i);return c}function Ce(){return!0}function we(){return!1}function Se(n,e){return n===function(){try{return y.activeElement}catch(t){}}()==("focus"===e)}function ke(d,e,l,p,r,c){var o,a;if("object"==typeof e){for(a in"string"!=typeof l&&(p=p||l,l=void 0),e)ke(d,a,l,p,e[a],c);return d}if(null==p&&null==r?(r=l,p=l=void 0):null==r&&("string"==typeof l?(r=p,p=void 0):(r=p,p=l,l=void 0)),!1===r)r=we;else if(!r)return d;return 1===c&&(o=r,r=function(t){return ln().off(t),o.apply(this,arguments)},r.guid=o.guid||(o.guid=ln.guid++)),d.each(function(){ln.event.add(this,e,r,p,l)})}function je(a,s,t){t?(U.set(a,s,!1),ln.event.add(a,s,{namespace:!1,handler:function(n){var e,a,i=U.get(this,s);if(!(1&n.isTrigger&&this[s]))i.length&&(U.set(this,s,{value:ln.event.trigger(ln.extend(i[0],ln.Event.prototype),i.slice(1),this)}),n.stopImmediatePropagation());else if(i.length)(ln.event.special[s]||{}).delegateType&&n.stopPropagation();else if(i=an.call(arguments),U.set(this,s,i),e=t(this,s),this[s](),i!==(a=U.get(this,s))||e?U.set(this,s,!1):a={},i!==a)return n.stopImmediatePropagation(),n.preventDefault(),a&&a.value}})):void 0===U.get(a,s)&&ln.event.add(a,s,Ce)}function Ne(n,e){return S(n,"table")&&S(11===e.nodeType?e.firstChild:e,"tr")&&ln(n).children("tbody")[0]||n}function He(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function Oe(t){return"true/"===(t.type||"").slice(0,5)?t.type=t.type.slice(5):t.removeAttribute("type"),t}function Pe(d,e){var t,n,r,i,o,a;if(1===e.nodeType){if(U.hasData(d)&&(a=U.get(d).events))for(r in U.remove(e,"handle events"),a)for(t=0,n=a[r].length;t<n;t++)ln.event.add(e,r,a[r][t]);V.hasData(d)&&(i=V.access(d),o=ln.extend({},i),V.set(e,o))}}function Re(a,e){var t=e.nodeName.toLowerCase();"input"===t&&he.test(a.type)?e.checked=a.checked:"input"!==t&&"textarea"!==t||(e.defaultValue=a.defaultValue)}function Ie(p,e,t,n){e=on(e);var r,u,o,a,s,l,c=0,f=p.length,d=e[0],m=dn(d);if(m||1<f&&"string"==typeof d&&!rn.checkClone&&Te.test(d))return p.each(function(a){var s=p.eq(a);m&&(e[0]=d.call(this,a,s.html())),Ie(s,e,t,n)});if(f&&(u=(r=xe(e,p[0].ownerDocument,!1,p,n)).firstChild,1===r.childNodes.length&&(r=u),u||n)){for(a=(o=ln.map(pe(r,"script"),He)).length;c<f;c++)s=r,c!=f-1&&(s=ln.clone(s,!0,!0),a&&ln.merge(o,pe(s,"script"))),t.call(p[c],s,c);if(a)for(l=o[o.length-1].ownerDocument,ln.map(o,Oe),c=0;c<a;c++)s=o[c],fe.test(s.type||"")&&!U.access(s,"globalEval")&&ln.contains(l,s)&&(s.src&&"module"!==(s.type||"").toLowerCase()?ln._evalUrl&&!s.noModule&&ln._evalUrl(s.src,{nonce:s.nonce||s.getAttribute("nonce")},l):i(s.textContent.replace(Ee,""),s,l))}return p}function Me(a,e,t){for(var n,s=e?ln.filter(e,a):a,i=0;null!=(n=s[i]);i++)t||1!==n.nodeType||ln.cleanData(pe(n)),n.parentNode&&(t&&ae(n)&&ce(pe(n,"script")),n.parentNode.removeChild(n));return a}function _e(d,e,t){var n,r,i,o,a=d.style;return(t=t||Le(d))&&(""!==(o=t.getPropertyValue(e)||t[e])||ae(d)||(o=ln.style(d,e)),!rn.pixelBoxStyles()&&De.test(o)&&Be.test(e)&&(n=a.width,r=a.minWidth,i=a.maxWidth,a.minWidth=a.maxWidth=a.width=o,o=t.width,a.width=n,a.minWidth=r,a.maxWidth=i)),void 0===o?o:o+""}function ze(n,e){return{get:function(){return n()?void delete this.get:(this.get=e).apply(this,arguments)}}}function Ue(t){return ln.cssProps[t]||Xe[t]||(t in Fe?t:Xe[t]=function(a){for(var e=a[0].toUpperCase()+a.slice(1),t=We.length;t--;)if((a=We[t]+e)in Fe)return a}(t)||t)}function Ye(a,e,t){var n=ee.exec(e);return n?tn(0,n[2]-(t||0))+(n[3]||"px"):e}function et(d,e,t,n,l,i){var o="width"===e?1:0,a=0,s=0;if(t===(n?"border":"content"))return 0;for(;4>o;o+=2)"margin"===t&&(s+=ln.css(d,t+te[o],!0,l)),n?("content"===t&&(s-=ln.css(d,"padding"+te[o],!0,l)),"margin"!==t&&(s-=ln.css(d,"border"+te[o]+"Width",!0,l))):(s+=ln.css(d,"padding"+te[o],!0,l),"padding"===t?a+=ln.css(d,"border"+te[o]+"Width",!0,l):s+=ln.css(d,"border"+te[o]+"Width",!0,l));return!n&&0<=i&&(s+=tn(0,$t(d["offset"+e[0].toUpperCase()+e.slice(1)]-i-s-a-.5))||0),s}function tt(d,e,t){var l=Le(d),r=(!rn.boxSizingReliable()||t)&&"border-box"===ln.css(d,"boxSizing",!1,l),i=r,o=_e(d,e,l),a="offset"+e[0].toUpperCase()+e.slice(1);if(De.test(o)){if(!t)return o;o="auto"}return(!rn.boxSizingReliable()&&r||!rn.reliableTrDimensions()&&S(d,"tr")||"auto"===o||!parseFloat(o)&&"inline"===ln.css(d,"display",!1,l))&&d.getClientRects().length&&(r="border-box"===ln.css(d,"boxSizing",!1,l),(i=a in d)&&(o=d[a])),(o=parseFloat(o)||0)+et(d,e,t||(r?"border":"content"),i,l,o)+"px"}function nt(a,e,t,n,o){return new nt.prototype.init(a,e,t,n,o)}function en(){Je&&(!1===y.hidden&&Zt.requestAnimationFrame?Zt.requestAnimationFrame(en):Zt.setTimeout(en,ln.fx.interval),ln.fx.tick())}function ut(){return Zt.setTimeout(function(){Ke=void 0}),Ke=Date.now()}function lt(a,o){var t,n=0,s={height:a};for(o=o?1:0;4>n;n+=2-o)s["margin"+(t=te[n])]=s["padding"+t]=a;return o&&(s.opacity=s.width=a),s}function ct(s,e,t){for(var n,r=(ft.tweeners[e]||[]).concat(ft.tweeners["*"]),i=0,o=r.length;i<o;i++)if(n=r[i].call(t,e,s))return n}function ft(d,p,h){var g,f,i=0,o=ft.prefilters.length,m=ln.Deferred().always(function(){delete a.elem}),a=function(){if(f)return!1;for(var e=Ke||ut(),t=tn(0,s.startTime+s.duration-e),n=1-(t/s.duration||0),i=0,o=s.tweens.length;i<o;i++)s.tweens[i].run(n);return m.notifyWith(d,[s,n,t]),1>n&&o?t:(o||m.notifyWith(d,[s,1,0]),m.resolveWith(d,[s]),!1)},s=m.promise({elem:d,props:ln.extend({},p),opts:ln.extend(!0,{specialEasing:{},easing:ln.easing._default},h),originalProperties:p,originalOptions:h,startTime:Ke||ut(),duration:h.duration,tweens:[],createTween:function(e,t){var n=ln.Tween(d,s.opts,e,t,s.opts.specialEasing[e]||s.opts.easing);return s.tweens.push(n),n},stop:function(e){var t=0,n=e?s.tweens.length:0;if(f)return this;for(f=!0;t<n;t++)s.tweens[t].run(1);return e?(m.notifyWith(d,[s,1,0]),m.resolveWith(d,[s,e])):m.rejectWith(d,[s,e]),this}}),r=s.props;for(function(s,e){var t,n,r,i,o;for(t in s)if(r=e[n=z(t)],i=s[t],Array.isArray(i)&&(r=i[1],i=s[t]=i[0]),t!==n&&(s[n]=i,delete s[t]),(o=ln.cssHooks[n])&&("expand"in o))for(t in i=o.expand(i),delete s[n],i)(t in s)||(s[t]=i[t],e[t]=r);else e[n]=r}(r,s.opts.specialEasing);i<o;i++)if(g=ft.prefilters[i].call(s,d,r,s.opts))return dn(g.stop)&&(ln._queueHooks(s.elem,s.opts.queue).stop=g.stop.bind(g)),g;return ln.map(r,ct,s),dn(s.opts.start)&&s.opts.start.call(d,s),s.progress(s.opts.progress).done(s.opts.done,s.opts.complete).fail(s.opts.fail).always(s.opts.always),ln.fx.timer(ln.extend(a,{elem:d,anim:s,queue:s.opts.queue})),s}function dt(t){return(t.match(P)||[]).join(" ")}function vt(t){return t.getAttribute&&t.getAttribute("class")||""}function yt(t){return Array.isArray(t)?t:"string"==typeof t&&t.match(P)||[]}function bt(a,e,o,n){if(Array.isArray(e))ln.each(e,function(e,t){o||wt.test(a)?n(a,t):bt(a+"["+("object"==typeof t&&null!=t?e:"")+"]",t,o,n)});else if(o||"object"!==w(e))n(a,e);else for(var t in e)bt(a+"["+t+"]",e[t],o,n)}function Dt(t){return function(e,a){"string"!=typeof e&&(a=e,e="*");var n,s=0,i=e.toLowerCase().match(P)||[];if(dn(a))for(;n=i[s++];)"+"===n[0]?(n=n.slice(1)||"*",(t[n]=t[n]||[]).unshift(a)):(t[n]=t[n]||[]).push(a)}}function Ft(d,p,t,n){function r(e){var o;return a[e]=!0,ln.each(d[e]||[],function(d,e){var s=e(p,t,n);return"string"!=typeof s||i||a[s]?i?!(o=s):void 0:(p.dataTypes.unshift(s),r(s),!1)}),o}var a={},i=d===Ot;return r(p.dataTypes[0])||!a["*"]&&r("*")}function Bt(a,e){var t,n,o=ln.ajaxSettings.flatOptions||{};for(t in e)void 0!==e[t]&&((o[t]?a:n||(n={}))[t]=e[t]);return n&&ln.extend(!0,a,n),a}var $t=Math.ceil,tn=Math.max,nn=[],o=Object.getPrototypeOf,an=nn.slice,on=nn.flat?function(t){return nn.flat.call(t)}:function(t){return nn.concat.apply([],t)},s=nn.push,a=nn.indexOf,c={},u=c.toString,sn=c.hasOwnProperty,d=sn.toString,p=d.call(Object),rn={},dn=function(t){return"function"==typeof t&&"number"!=typeof t.nodeType&&"function"!=typeof t.item},v=function(t){return null!=t&&t===t.window},y=Zt.document,h={type:!0,src:!0,nonce:!0,noModule:!0},g="3.6.0",ln=function(n,e){return new ln.fn.init(n,e)};ln.fn=ln.prototype={jquery:g,constructor:ln,length:0,toArray:function(){return an.call(this)},get:function(t){return null==t?an.call(this):0>t?this[t+this.length]:this[t]},pushStack:function(n){var e=ln.merge(this.constructor(),n);return e.prevObject=this,e},each:function(t){return ln.each(this,t)},map:function(a){return this.pushStack(ln.map(this,function(e,t){return a.call(e,t,e)}))},slice:function(){return this.pushStack(an.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(ln.grep(this,function(n,e){return(e+1)%2}))},odd:function(){return this.pushStack(ln.grep(this,function(n,e){return e%2}))},eq:function(a){var o=this.length,t=+a+(0>a?o:0);return this.pushStack(0<=t&&t<o?[this[t]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:nn.sort,splice:nn.splice},ln.extend=ln.fn.extend=function(){var d,e,t,n,r,i,o=arguments[0]||{},p=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[p]||{},p++),"object"==typeof o||dn(o)||(o={}),p===s&&(o=this,p--);p<s;p++)if(null!=(d=arguments[p]))for(e in d)n=d[e],"__proto__"!==e&&o!==n&&(c&&n&&(ln.isPlainObject(n)||(r=Array.isArray(n)))?(t=o[e],i=r&&!Array.isArray(t)?[]:r||ln.isPlainObject(t)?t:{},r=!1,o[e]=ln.extend(c,i,n)):void 0!==n&&(o[e]=n));return o},ln.extend({expando:"jQuery"+(g+Math.random()).replace(/\D/g,""),isReady:!0,error:function(t){throw new Error(t)},noop:function(){},isPlainObject:function(a){var e,t;return a&&"[object Object]"===u.call(a)&&(!(e=o(a))||"function"==typeof(t=sn.call(e,"constructor")&&e.constructor)&&d.call(t)===p)},isEmptyObject:function(n){for(var e in n)return!1;return!0},globalEval:function(a,e,t){i(a,{nonce:e&&e.nonce},t)},each:function(a,e){var t,n=0;if(T(a))for(t=a.length;n<t&&!1!==e.call(a[n],n,a[n]);n++);else for(n in a)if(!1===e.call(a[n],n,a[n]))break;return a},makeArray:function(a,o){var t=o||[];return null!=a&&(T(Object(a))?ln.merge(t,"string"==typeof a?[a]:a):s.call(t,a)),t},inArray:function(o,e,t){return null==e?-1:a.call(e,o,t)},merge:function(a,e){for(var t=+e.length,n=0,o=a.length;n<t;n++)a[o++]=e[n];return a.length=o,a},grep:function(a,e,t){for(var s=[],r=0,i=a.length;r<i;r++)!e(a[r],r)!==!t&&s.push(a[r]);return s},map:function(s,e,t){var n,r,i=0,o=[];if(T(s))for(n=s.length;i<n;i++)null!=(r=e(s[i],i,t))&&o.push(r);else for(i in s)null!=(r=e(s[i],i,t))&&o.push(r);return on(o)},guid:1,support:rn}),"function"==typeof Symbol&&(ln.fn[Symbol.iterator]=nn[Symbol.iterator]),ln.each(["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error","Symbol"],function(n,e){c["[object "+e+"]"]=e.toLowerCase()});var f=function(_){function W(n,a,t,u){var g,o,s,l,c,f,h,b=a&&a.ownerDocument,y=a?a.nodeType:9;if(t=t||[],"string"!=typeof n||!n||1!==y&&9!==y&&11!==y)return t;if(!u&&(De(a),a=a||d,Le)){if(11!==y&&(c=U.exec(n)))if(!(g=c[1])){if(c[2])return k.apply(t,a.getElementsByTagName(n)),t;if((g=c[3])&&Ee.getElementsByClassName&&a.getElementsByClassName)return k.apply(t,a.getElementsByClassName(g)),t}else if(9===y){if(!(s=a.getElementById(g)))return t;if(s.id===g)return t.push(s),t}else if(b&&(s=b.getElementById(g))&&qe(a,s)&&s.id===g)return t.push(s),t;if(Ee.qsa&&!T[n+" "]&&(!p||!p.test(n))&&(1!==y||"object"!==a.nodeName.toLowerCase())){if(h=n,b=a,1===y&&(I.test(n)||O.test(n))){for((b=V.test(n)&&me(a.parentNode)||a)===a&&Ee.scope||((l=a.getAttribute("id"))?l=l.replace(K,J):a.setAttribute("id",l=He)),o=(f=r(n)).length;o--;)f[o]=(l?"#"+l:":scope")+" "+ye(f[o]);h=f.join(",")}try{return k.apply(t,b.querySelectorAll(h)),t}catch(e){T(n,!0)}finally{l===He&&a.removeAttribute("id")}}}return Ae(n.replace(H,"$1"),a,t,u)}function e(){var a=[];return function e(t,n){return a.push(t+" ")>ke.cacheLength&&delete e[a.shift()],e[t+" "]=n}}function se(t){return t[He]=!0,t}function ue(n){var e=d.createElement("fieldset");try{return!!n(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function ce(a,e){for(var t=a.split("|"),n=t.length;n--;)ke.attrHandle[t[n]]=e}function fe(a,e){var t=e&&a,n=t&&1===a.nodeType&&1===e.nodeType&&a.sourceIndex-e.sourceIndex;if(n)return n;if(t)for(;t=t.nextSibling;)if(t===e)return-1;return a?1:-1}function de(n){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===n}}function pe(a){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===a}}function he(n){return function(a){return"form"in a?a.parentNode&&!1===a.disabled?"label"in a?"label"in a.parentNode?a.parentNode.disabled===n:a.disabled===n:a.isDisabled===n||a.isDisabled!==!n&&ee(a)===n:a.disabled===n:"label"in a&&a.disabled===n}}function ge(s){return se(function(e){return e=+e,se(function(t,n){for(var r,i=s([],t.length,e),o=i.length;o--;)t[r=i[o]]&&(t[r]=!(n[r]=t[r]))})})}function me(t){return t&&void 0!==t.getElementsByTagName&&t}function ve(){}function ye(a){for(var e=0,t=a.length,n="";e<t;e++)n+=a[e].value;return n}function be(p,e,t){var h=e.dir,r=e.next,i=r||h,o=t&&"parentNode"===i,a=y++;return e.first?function(e,t,n){for(;e=e[h];)if(1===e.nodeType||o)return p(e,t,n);return!1}:function(e,t,n){var s,l,c,u=[Pe,a];if(n){for(;e=e[h];)if((1===e.nodeType||o)&&p(e,t,n))return!0;}else for(;e=e[h];)if(1===e.nodeType||o)if(l=(c=e[He]||(e[He]={}))[e.uniqueID]||(c[e.uniqueID]={}),r&&r===e.nodeName.toLowerCase())e=e[h]||e;else{if((s=l[i])&&s[0]===Pe&&s[1]===a)return u[2]=s[2];if(l[i]=u,u[2]=p(e,t,n))return!0}return!1}}function xe(a){return 1<a.length?function(e,t,n){for(var o=a.length;o--;)if(!a[o](e,t,n))return!1;return!0}:a[0]}function we(d,e,t,n,r){for(var i,o=[],a=0,s=d.length;a<s;a++)(i=d[a])&&(t&&!t(i,n,r)||(o.push(i),null!=e&&e.push(a)));return o}function Te(y,e,b,n,r,a){return n&&!n[He]&&(n=Te(n)),r&&!r[He]&&(r=Te(r,a)),se(function(i,x,a,s){var u,l,c,f=[],d=[],p=x.length,h=i||function(a,e,t){for(var n=0,o=e.length;n<o;n++)W(a,e[n],t);return t}(e||"*",a.nodeType?[a]:a,[]),g=y&&(i||!e)?we(h,f,y,a,s):h,m=b?r||(i?y:p||n)?[]:x:g;if(b&&b(g,m,a,s),n)for(u=we(m,d),n(u,[],a,s),l=u.length;l--;)(c=u[l])&&(m[d[l]]=!(g[d[l]]=c));if(!i)m=we(m===x?m.splice(p,m.length):m),r?r(null,x,m,s):k.apply(x,m);else if(r||y){if(r){for(u=[],l=m.length;l--;)(c=m[l])&&u.push(g[l]=c);r(null,m=[],u,s)}for(l=m.length;l--;)(c=m[l])&&-1<(u=r?A(i,c):f[l])&&(i[u]=!(x[u]=c))}})}function Ce(r){for(var l,e,t,n=r.length,o=ke.relative[r[0].type],i=o||ke.relative[" "],s=o?1:0,p=be(function(t){return t===l},i,!0),c=be(function(t){return-1<A(l,t)},i,!0),u=[function(t,e,n){var s=!o&&(n||e!==je)||((l=e).nodeType?p(t,e,n):c(t,e,n));return l=null,s}];s<n;s++)if(e=ke.relative[r[s].type])u=[be(xe(u),e)];else{if((e=ke.filter[r[s].type].apply(null,r[s].matches))[He]){for(t=++s;t<n&&!ke.relative[r[t].type];t++);return Te(1<s&&xe(u),1<s&&ye(r.slice(0,s-1).concat({value:" "===r[s-2].type?"*":""})).replace(H,"$1"),e,s<t&&Ce(r.slice(s,t)),t<n&&Ce(r=r.slice(t)),t<n&&ye(r))}u.push(e)}return xe(u)}var Se,Ee,ke,Ne,n,r,a,Ae,je,l,c,De,d,o,Le,p,s,u,qe,He="sizzle"+1*new Date,h=_.document,Pe=0,y=0,i=e(),b=e(),x=e(),T=e(),C=function(n,e){return n===e&&(c=!0),0},w={}.hasOwnProperty,t=[],S=t.pop,E=t.push,k=t.push,N=t.slice,A=function(a,e){for(var t=0,n=a.length;t<n;t++)if(a[t]===e)return t;return-1},j="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",D="[\\x20\\t\\r\\n\\f]",L="(?:\\\\[\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",q=/[\x20\t\r\n\f]+/g,H=/^[\x20\t\r\n\f]+|((?:^|[^\\])(?:\\.)*)[\x20\t\r\n\f]+$/g,P=/^[\x20\t\r\n\f]*,[\x20\t\r\n\f]*/,O=/^[\x20\t\r\n\f]*([>+~]|[\x20\t\r\n\f])[\x20\t\r\n\f]*/,I=/[\x20\t\r\n\f]|>/,M=/:((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)(?:\((('((?:\\.|[^\\'])*)'|"((?:\\.|[^\\"])*)")|((?:\\.|[^\\()[\]]|\[[\x20\t\r\n\f]*((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)(?:[\x20\t\r\n\f]*([*^$|!~]?=)[\x20\t\r\n\f]*(?:'((?:\\.|[^\\'])*)'|"((?:\\.|[^\\"])*)"|((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+))|)[\x20\t\r\n\f]*\])*)|.*)\)|)/,B=/^(?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+$/,R={ID:/^#((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)/,CLASS:/^\.((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)/,TAG:/^((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+|[*])/,ATTR:/^\[[\x20\t\r\n\f]*((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)(?:[\x20\t\r\n\f]*([*^$|!~]?=)[\x20\t\r\n\f]*(?:'((?:\\.|[^\\'])*)'|"((?:\\.|[^\\"])*)"|((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+))|)[\x20\t\r\n\f]*\]/,PSEUDO:/^:((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)(?:\((('((?:\\.|[^\\'])*)'|"((?:\\.|[^\\"])*)")|((?:\\.|[^\\()[\]]|\[[\x20\t\r\n\f]*((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+)(?:[\x20\t\r\n\f]*([*^$|!~]?=)[\x20\t\r\n\f]*(?:'((?:\\.|[^\\'])*)'|"((?:\\.|[^\\"])*)"|((?:\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\[^\r\n\f]|[\w-]|[^\0-\x7f])+))|)[\x20\t\r\n\f]*\])*)|.*)\)|)/,CHILD:/^:(only|first|last|nth|nth-last)-(child|of-type)(?:\([\x20\t\r\n\f]*(even|odd|(([+-]|)(\d*)n|)[\x20\t\r\n\f]*(?:([+-]|)[\x20\t\r\n\f]*(\d+)|))[\x20\t\r\n\f]*\)|)/i,bool:/^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,needsContext:/^[\x20\t\r\n\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\([\x20\t\r\n\f]*((?:-\d)?\d*)[\x20\t\r\n\f]*\)|)(?=[^-]|$)/i},F=/HTML$/i,z=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,U=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,V=/[+~]/,Y=/\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\([^\r\n\f])/g,Q=function(a,e){var t=String.fromCharCode,o="0x"+a.slice(1)-65536;return e||(0>o?t(o+65536):t(55296|o>>10,56320|1023&o))},K=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,J=function(n,e){return e?"\0"===n?"\uFFFD":n.slice(0,-1)+"\\"+n.charCodeAt(n.length-1).toString(16)+" ":"\\"+n},Z=function(){De()},ee=be(function(t){return!0===t.disabled&&"fieldset"===t.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{k.apply(t=N.call(h.childNodes),h.childNodes),t[h.childNodes.length].nodeType}catch(n){k={apply:t.length?function(n,e){E.apply(n,N.call(e))}:function(a,e){for(var t=a.length,n=0;a[t++]=e[n++];);a.length=t-1}}}for(Se in Ee=W.support={},n=W.isXML=function(a){var e=a&&a.namespaceURI,t=a&&(a.ownerDocument||a).documentElement;return!F.test(e||t&&t.nodeName||"HTML")},De=W.setDocument=function(r){var e,t,i=r?r.ownerDocument||r:h;return i!=d&&9===i.nodeType&&i.documentElement?(o=(d=i).documentElement,Le=!n(d),h!=d&&(t=d.defaultView)&&t.top!==t&&(t.addEventListener?t.addEventListener("unload",Z,!1):t.attachEvent&&t.attachEvent("onunload",Z)),Ee.scope=ue(function(t){return o.appendChild(t).appendChild(d.createElement("div")),void 0!==t.querySelectorAll&&!t.querySelectorAll(":scope fieldset div").length}),Ee.attributes=ue(function(t){return t.className="i",!t.getAttribute("className")}),Ee.getElementsByTagName=ue(function(t){return t.appendChild(d.createComment("")),!t.getElementsByTagName("*").length}),Ee.getElementsByClassName=$.test(d.getElementsByClassName),Ee.getById=ue(function(t){return o.appendChild(t).id=He,!d.getElementsByName||!d.getElementsByName(He).length}),Ee.getById?(ke.filter.ID=function(n){var a=n.replace(Y,Q);return function(t){return t.getAttribute("id")===a}},ke.find.ID=function(a,e){if(void 0!==e.getElementById&&Le){var t=e.getElementById(a);return t?[t]:[]}}):(ke.filter.ID=function(n){var a=n.replace(Y,Q);return function(t){var e=void 0!==t.getAttributeNode&&t.getAttributeNode("id");return e&&e.value===a}},ke.find.ID=function(a,e){if(void 0!==e.getElementById&&Le){var t,n,s,i=e.getElementById(a);if(i){if((t=i.getAttributeNode("id"))&&t.value===a)return[i];for(s=e.getElementsByName(a),n=0;i=s[n++];)if((t=i.getAttributeNode("id"))&&t.value===a)return[i]}return[]}}),ke.find.TAG=Ee.getElementsByTagName?function(n,e){return void 0===e.getElementsByTagName?Ee.qsa?e.querySelectorAll(n):void 0:e.getElementsByTagName(n)}:function(a,e){var t,n=[],s=0,i=e.getElementsByTagName(a);if("*"===a){for(;t=i[s++];)1===t.nodeType&&n.push(t);return n}return i},ke.find.CLASS=Ee.getElementsByClassName&&function(n,e){if(void 0!==e.getElementsByClassName&&Le)return e.getElementsByClassName(n)},s=[],p=[],(Ee.qsa=$.test(d.querySelectorAll))&&(ue(function(n){var e;o.appendChild(n).innerHTML="<a id='"+He+"'></a><select id='"+He+"-\r\\' msallowcapture=''><option selected=''></option></select>",n.querySelectorAll("[msallowcapture^='']").length&&p.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),n.querySelectorAll("[selected]").length||p.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|"+j+")"),n.querySelectorAll("[id~="+He+"-]").length||p.push("~="),(e=d.createElement("input")).setAttribute("name",""),n.appendChild(e),n.querySelectorAll("[name='']").length||p.push("\\[[\\x20\\t\\r\\n\\f]*name[\\x20\\t\\r\\n\\f]*=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),n.querySelectorAll(":checked").length||p.push(":checked"),n.querySelectorAll("a#"+He+"+*").length||p.push(".#.+[+~]"),n.querySelectorAll("\\\f"),p.push("[\\r\\n\\f]")}),ue(function(n){n.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var e=d.createElement("input");e.setAttribute("type","hidden"),n.appendChild(e).setAttribute("name","D"),n.querySelectorAll("[name=d]").length&&p.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?="),2!==n.querySelectorAll(":enabled").length&&p.push(":enabled",":disabled"),o.appendChild(n).disabled=!0,2!==n.querySelectorAll(":disabled").length&&p.push(":enabled",":disabled"),n.querySelectorAll("*,:x"),p.push(",.*:")})),(Ee.matchesSelector=$.test(u=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ue(function(t){Ee.disconnectedMatch=u.call(t,"*"),u.call(t,"[s!='']:x"),s.push("!=",":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+("\\[[\\x20\\t\\r\\n\\f]*("+L+")(?:"+D+"*([*^$|!~]?=)"+D+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+D+"*\\]")+")*)|.*)\\)|)")}),p=p.length&&new RegExp(p.join("|")),s=s.length&&new RegExp(s.join("|")),e=$.test(o.compareDocumentPosition),qe=e||$.test(o.contains)?function(a,e){var t=9===a.nodeType?a.documentElement:a,n=e&&e.parentNode;return a===n||n&&1===n.nodeType&&(t.contains?t.contains(n):a.compareDocumentPosition&&16&a.compareDocumentPosition(n))}:function(n,e){if(e)for(;e=e.parentNode;)if(e===n)return!0;return!1},C=e?function(n,e){if(n===e)return c=!0,0;var t=!n.compareDocumentPosition-!e.compareDocumentPosition;return t||(1&(t=(n.ownerDocument||n)==(e.ownerDocument||e)?n.compareDocumentPosition(e):1)||!Ee.sortDetached&&e.compareDocumentPosition(n)===t?n==d||n.ownerDocument==h&&qe(h,n)?-1:e==d||e.ownerDocument==h&&qe(h,e)?1:l?A(l,n)-A(l,e):0:4&t?-1:1)}:function(p,e){if(p===e)return c=!0,0;var t,n=0,r=p.parentNode,u=e.parentNode,g=[p],a=[e];if(!r||!u)return p==d?-1:e==d?1:r?-1:u?1:l?A(l,p)-A(l,e):0;if(r===u)return fe(p,e);for(t=p;t=t.parentNode;)g.unshift(t);for(t=e;t=t.parentNode;)a.unshift(t);for(;g[n]===a[n];)n++;return n?fe(g[n],a[n]):g[n]==h?-1:a[n]==h?1:0},d):d},W.matches=function(n,e){return W(n,null,null,e)},W.matchesSelector=function(n,e){if(De(n),Ee.matchesSelector&&Le&&!T[e+" "]&&(!s||!s.test(e))&&(!p||!p.test(e)))try{var t=u.call(n,e);if(t||Ee.disconnectedMatch||n.document&&11!==n.document.nodeType)return t}catch(t){T(e,!0)}return 0<W(e,d,null,[n]).length},W.contains=function(n,e){return(n.ownerDocument||n)!=d&&De(n),qe(n,e)},W.attr=function(n,e){(n.ownerDocument||n)!=d&&De(n);var t=ke.attrHandle[e.toLowerCase()],a=t&&w.call(ke.attrHandle,e.toLowerCase())?t(n,e,!Le):void 0;return void 0===a?Ee.attributes||!Le?n.getAttribute(e):(a=n.getAttributeNode(e))&&a.specified?a.value:null:a},W.escape=function(t){return(t+"").replace(K,J)},W.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},W.uniqueSort=function(n){var e,t=[],a=0,s=0;if(c=!Ee.detectDuplicates,l=!Ee.sortStable&&n.slice(0),n.sort(C),c){for(;e=n[s++];)e===n[s]&&(a=t.push(s));for(;a--;)n.splice(t[a],1)}return l=null,n},Ne=W.getText=function(a){var e,t="",n=0,s=a.nodeType;if(!s)for(;e=a[n++];)t+=Ne(e);else if(1===s||9===s||11===s){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)t+=Ne(a)}else if(3===s||4===s)return a.nodeValue;return t},ke=W.selectors={cacheLength:50,createPseudo:se,match:R,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(Y,Q),t[3]=(t[3]||t[4]||t[5]||"").replace(Y,Q),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||W.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&W.error(t[0]),t},PSEUDO:function(a){var e,t=!a[6]&&a[2];return R.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":t&&M.test(t)&&(e=r(t,!0))&&(e=t.indexOf(")",t.length-e)-t.length)&&(a[0]=a[0].slice(0,e),a[2]=t.slice(0,e)),a.slice(0,3))}},filter:{TAG:function(n){var a=n.replace(Y,Q).toLowerCase();return"*"===n?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===a}},CLASS:function(n){var a=i[n+" "];return a||(a=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+n+"("+D+"|$)"))&&i(n,function(t){return a.test("string"==typeof t.className&&t.className||void 0!==t.getAttribute&&t.getAttribute("class")||"")})},ATTR:function(a,e,o){return function(n){var s=W.attr(n,a);return null==s?"!="===e:!e||(s+="","="===e?s===o:"!="===e?s!==o:"^="===e?o&&0===s.indexOf(o):"*="===e?o&&-1<s.indexOf(o):"$="===e?o&&s.slice(-o.length)===o:"~="===e?-1<(" "+s.replace(q," ")+" ").indexOf(o):"|="==e&&(s===o||s.slice(0,o.length+1)===o+"-"))}},CHILD:function(u,e,t,n,r){var i="nth"!==u.slice(0,3),o="last"!==u.slice(-4),a="of-type"===e;return 1===n&&0===r?function(t){return!!t.parentNode}:function(e,t,x){var T,l,c,f,d,p,C=i==o?"previousSibling":"nextSibling",g=e.parentNode,m=a&&e.nodeName.toLowerCase(),v=!x&&!a,y=!1;if(g){if(i){for(;C;){for(f=e;f=f[C];)if(a?f.nodeName.toLowerCase()===m:1===f.nodeType)return!1;p=C="only"===u&&!p&&"nextSibling"}return!0}if(p=[o?g.firstChild:g.lastChild],o&&v){for(y=(d=(T=(l=(c=(f=g)[He]||(f[He]={}))[f.uniqueID]||(c[f.uniqueID]={}))[u]||[])[0]===Pe&&T[1])&&T[2],f=d&&g.childNodes[d];f=++d&&f&&f[C]||(y=d=0)||p.pop();)if(1===f.nodeType&&++y&&f===e){l[u]=[Pe,d,y];break}}else if(v&&(y=d=(T=(l=(c=(f=e)[He]||(f[He]={}))[f.uniqueID]||(c[f.uniqueID]={}))[u]||[])[0]===Pe&&T[1]),!1===y)for(;(f=++d&&f&&f[C]||(y=d=0)||p.pop())&&((a?f.nodeName.toLowerCase()!==m:1!==f.nodeType)||!++y||(v&&((l=(c=f[He]||(f[He]={}))[f.uniqueID]||(c[f.uniqueID]={}))[u]=[Pe,y]),f!==e)););return(y-=r)==n||0==y%n&&0<=y/n}}},PSEUDO:function(a,s){var t,d=ke.pseudos[a]||ke.setFilters[a.toLowerCase()]||W.error("unsupported pseudo: "+a);return d[He]?d(s):1<d.length?(t=[a,a,"",s],ke.setFilters.hasOwnProperty(a.toLowerCase())?se(function(t,e){for(var n,i=d(t,s),o=i.length;o--;)t[n=A(t,i[o])]=!(e[n]=i[o])}):function(n){return d(n,0,t)}):d}},pseudos:{not:se(function(o){var s=[],t=[],n=a(o.replace(H,"$1"));return n[He]?se(function(r,e,t,d){for(var i,o=n(r,null,d,[]),a=r.length;a--;)(i=o[a])&&(r[a]=!(e[a]=i))}):function(a,e,i){return s[0]=a,n(s,null,i,t),s[0]=null,!t.pop()}}),has:se(function(n){return function(e){return 0<W(n,e).length}}),contains:se(function(n){return n=n.replace(Y,Q),function(e){return-1<(e.textContent||Ne(e)).indexOf(n)}}),lang:se(function(a){return B.test(a||"")||W.error("unsupported lang: "+a),a=a.replace(Y,Q).toLowerCase(),function(e){var t;do if(t=Le?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===a||0===t.indexOf(a+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=_.location&&_.location.hash;return t&&t.slice(1)===e.id},root:function(t){return t===o},focus:function(t){return t===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:he(!1),disabled:he(!0),checked:function(n){var e=n.nodeName.toLowerCase();return"input"===e&&!!n.checked||"option"===e&&!!n.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(6>t.nodeType)return!1;return!0},parent:function(t){return!ke.pseudos.empty(t)},header:function(t){return X.test(t.nodeName)},input:function(t){return z.test(t.nodeName)},button:function(n){var e=n.nodeName.toLowerCase();return"input"===e&&"button"===n.type||"button"===e},text:function(n){var e;return"input"===n.nodeName.toLowerCase()&&"text"===n.type&&(null==(e=n.getAttribute("type"))||"text"===e.toLowerCase())},first:ge(function(){return[0]}),last:ge(function(n,e){return[e-1]}),eq:ge(function(a,e,t){return[0>t?t+e:t]}),even:ge(function(a,e){for(var t=0;t<e;t+=2)a.push(t);return a}),odd:ge(function(a,e){for(var t=1;t<e;t+=2)a.push(t);return a}),lt:ge(function(a,e,t){for(var n=0>t?t+e:t>e?e:t;0<=--n;)a.push(n);return a}),gt:ge(function(a,e,t){for(var n=0>t?t+e:t;++n<e;)a.push(n);return a})}},ke.pseudos.nth=ke.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})ke.pseudos[Se]=de(Se);for(Se in{submit:!0,reset:!0})ke.pseudos[Se]=pe(Se);return ve.prototype=ke.filters=ke.pseudos,ke.setFilters=new ve,r=W.tokenize=function(r,e){var t,d,p,o,a,s,u,l=b[r+" "];if(l)return e?0:l.slice(0);for(a=r,s=[],u=ke.preFilter;a;){for(o in t&&!(d=P.exec(a))||(d&&(a=a.slice(d[0].length)||a),s.push(p=[])),t=!1,(d=O.exec(a))&&(t=d.shift(),p.push({value:t,type:d[0].replace(H," ")}),a=a.slice(t.length)),ke.filter)(d=R[o].exec(a))&&(!u[o]||(d=u[o](d)))&&(t=d.shift(),p.push({value:t,type:o,matches:d}),a=a.slice(t.length));if(!t)break}return e?a.length:a?W.error(r):b(r,s).slice(0)},a=W.compile=function(a,e){var t,n=[],i=[],o=x[a+" "];if(!o){for(e||(e=r(a)),t=e.length;t--;)(o=Ce(e[t]))[He]?n.push(o):i.push(o);o=x(a,function(r,e){var t=0<e.length,n=0<r.length,a=function(i,l,a,s,p){var c,u,h,f=0,v="0",y=i&&[],b=[],x=je,T=i||n&&ke.find.TAG("*",p),C=Pe+=null==x?1:Math.random()||.1,w=T.length;for(p&&(je=l==d||l||p);v!==w&&null!=(c=T[v]);v++){if(n&&c){for(u=0,l||c.ownerDocument==d||(De(c),a=!Le);h=r[u++];)if(h(c,l||d,a)){s.push(c);break}p&&(Pe=C)}t&&((c=!h&&c)&&f--,i&&y.push(c))}if(f+=v,t&&v!==f){for(u=0;h=e[u++];)h(y,b,l,a);if(i){if(0<f)for(;v--;)y[v]||b[v]||(b[v]=S.call(s));b=we(b)}k.apply(s,b),p&&!i&&0<b.length&&1<f+e.length&&W.uniqueSort(s)}return p&&(Pe=C,je=x),y};return t?se(a):a}(i,n)),o.selector=a}return o},Ae=W.select=function(s,h,m,n){var y,o,u,l,c,f="function"==typeof s&&s,d=!n&&r(s=f.selector||s);if(m=m||[],1===d.length){if(2<(o=d[0]=d[0].slice(0)).length&&"ID"===(u=o[0]).type&&9===h.nodeType&&Le&&ke.relative[o[1].type]){if(!(h=(ke.find.ID(u.matches[0].replace(Y,Q),h)||[])[0]))return m;f&&(h=h.parentNode),s=s.slice(o.shift().value.length)}for(y=R.needsContext.test(s)?0:o.length;y--&&(u=o[y],!ke.relative[l=u.type]);)if((c=ke.find[l])&&(n=c(u.matches[0].replace(Y,Q),V.test(o[0].type)&&me(h.parentNode)||h))){if(o.splice(y,1),!(s=n.length&&ye(o)))return k.apply(m,n),m;break}}return(f||a(s,d))(n,h,!Le,m,!h||V.test(s)&&me(h.parentNode)||h),m},Ee.sortStable=He.split("").sort(C).join("")===He,Ee.detectDuplicates=!!c,De(),Ee.sortDetached=ue(function(t){return 1&t.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(t){return t.innerHTML="<a href='#'></a>","#"===t.firstChild.getAttribute("href")})||ce("type|href|height|width",function(a,e,t){if(!t)return a.getAttribute(e,"type"===e.toLowerCase()?1:2)}),Ee.attributes&&ue(function(t){return t.innerHTML="<input/>",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")})||ce("value",function(a,e,t){if(!t&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ue(function(t){return null==t.getAttribute("disabled")})||ce(j,function(a,e,t){var o;if(!t)return!0===a[e]?e.toLowerCase():(o=a.getAttributeNode(e))&&o.specified?o.value:null}),W}(Zt);ln.find=f,ln.expr=f.selectors,ln.expr[":"]=ln.expr.pseudos,ln.uniqueSort=ln.unique=f.uniqueSort,ln.text=f.getText,ln.isXMLDoc=f.isXML,ln.contains=f.contains,ln.escapeSelector=f.escape;var b=function(a,e,t){for(var n=[];(a=a[e])&&9!==a.nodeType;)if(1===a.nodeType){if(void 0!==t&&ln(a).is(t))break;n.push(a)}return n},x=function(a,e){for(var t=[];a;a=a.nextSibling)1===a.nodeType&&a!==e&&t.push(a);return t},k=ln.expr.match.needsContext,N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;ln.filter=function(a,e,t){var n=e[0];return t&&(a=":not("+a+")"),1===e.length&&1===n.nodeType?ln.find.matchesSelector(n,a)?[n]:[]:ln.find.matches(a,ln.grep(e,function(t){return 1===t.nodeType}))},ln.fn.extend({find:function(a){var o,t,n=this.length,s=this;if("string"!=typeof a)return this.pushStack(ln(a).filter(function(){for(o=0;o<n;o++)if(ln.contains(s[o],this))return!0}));for(t=this.pushStack([]),o=0;o<n;o++)ln.find(a,s[o],t);return 1<n?ln.uniqueSort(t):t},filter:function(t){return this.pushStack(r(this,t||[],!1))},not:function(t){return this.pushStack(r(this,t||[],!0))},is:function(t){return!!r(this,"string"==typeof t&&k.test(t)?ln(t):t||[],!1).length}});var A,j=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(ln.fn.init=function(a,o,s){var n,r;if(!a)return this;if(s=s||A,"string"==typeof a){if(!(n="<"===a[0]&&">"===a[a.length-1]&&3<=a.length?[null,a,null]:j.exec(a))||!n[1]&&o)return!o||o.jquery?(o||s).find(a):this.constructor(o).find(a);if(n[1]){if(o=o instanceof ln?o[0]:o,ln.merge(this,ln.parseHTML(n[1],o&&o.nodeType?o.ownerDocument||o:y,!0)),N.test(n[1])&&ln.isPlainObject(o))for(n in o)dn(this[n])?this[n](o[n]):this.attr(n,o[n]);return this}return(r=y.getElementById(n[2]))&&(this[0]=r,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):dn(a)?void 0===s.ready?a(ln):s.ready(a):ln.makeArray(a,this)}).prototype=ln.fn,A=ln(y);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};ln.fn.extend({has:function(a){var o=ln(a,this),t=o.length;return this.filter(function(){for(var n=0;n<t;n++)if(ln.contains(this,o[n]))return!0})},closest:function(s,d){var t,n=0,r=this.length,i=[],o="string"!=typeof s&&ln(s);if(!k.test(s))for(;n<r;n++)for(t=this[n];t&&t!==d;t=t.parentNode)if(11>t.nodeType&&(o?-1<o.index(t):1===t.nodeType&&ln.find.matchesSelector(t,s))){i.push(t);break}return this.pushStack(1<i.length?ln.uniqueSort(i):i)},index:function(t){return t?"string"==typeof t?a.call(ln(t),this[0]):a.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(n,e){return this.pushStack(ln.uniqueSort(ln.merge(this.get(),ln(n,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),ln.each({parent:function(n){var e=n.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return b(t,"parentNode")},parentsUntil:function(a,e,t){return b(a,"parentNode",t)},next:function(t){return D(t,"nextSibling")},prev:function(t){return D(t,"previousSibling")},nextAll:function(t){return b(t,"nextSibling")},prevAll:function(t){return b(t,"previousSibling")},nextUntil:function(a,e,t){return b(a,"nextSibling",t)},prevUntil:function(a,e,t){return b(a,"previousSibling",t)},siblings:function(t){return x((t.parentNode||{}).firstChild,t)},children:function(t){return x(t.firstChild)},contents:function(t){return null!=t.contentDocument&&o(t.contentDocument)?t.contentDocument:(S(t,"template")&&(t=t.content||t),ln.merge([],t.childNodes))}},function(a,e){ln.fn[a]=function(t,n){var o=ln.map(this,e,t);return"Until"!==a.slice(-5)&&(n=t),n&&"string"==typeof n&&(o=ln.filter(n,o)),1<this.length&&(H[a]||ln.uniqueSort(o),L.test(a)&&o.reverse()),this.pushStack(o)}});var P=/[^\x20\t\r\n\f]+/g;ln.Callbacks=function(d){d="string"==typeof d?function(n){var a={};return ln.each(n.match(P)||[],function(t,e){a[e]=!0}),a}(d):ln.extend({},d);var p,c,n,h,g=[],f=[],a=-1,s=function(){for(h=h||d.once,n=p=!0;f.length;a=-1)for(c=f.shift();++a<g.length;)!1===g[a].apply(c[0],c[1])&&d.stopOnFalse&&(a=g.length,c=!1);d.memory||(c=!1),p=!1,h&&(g=c?[]:"")},u={add:function(){return g&&(c&&!p&&(a=g.length-1,f.push(c)),function e(t){ln.each(t,function(t,n){dn(n)?d.unique&&u.has(n)||g.push(n):n&&n.length&&"string"!==w(n)&&e(n)})}(arguments),c&&!p&&s()),this},remove:function(){return ln.each(arguments,function(o,e){for(var t;-1<(t=ln.inArray(e,g,t));)g.splice(t,1),t<=a&&a--}),this},has:function(t){return t?-1<ln.inArray(t,g):0<g.length},empty:function(){return g&&(g=[]),this},disable:function(){return h=f=[],g=c="",this},disabled:function(){return!g},lock:function(){return h=f=[],c||p||(g=c=""),this},locked:function(){return!!h},fireWith:function(t,e){return h||(e=[t,(e=e||[]).slice?e.slice():e],f.push(e),p||s()),this},fire:function(){return u.fireWith(this,arguments),this},fired:function(){return!!n}};return u},ln.extend({Deferred:function(a){var d=[["notify","progress",ln.Callbacks("memory"),ln.Callbacks("memory"),2],["resolve","done",ln.Callbacks("once memory"),ln.Callbacks("once memory"),0,"resolved"],["reject","fail",ln.Callbacks("once memory"),ln.Callbacks("once memory"),1,"rejected"]],e="pending",t={state:function(){return e},always:function(){return l.done(arguments).fail(arguments),this},catch:function(n){return t.then(null,n)},pipe:function(){var a=arguments;return ln.Deferred(function(t){ln.each(d,function(e,n){var o=dn(a[n[4]])&&a[n[4]];l[n[1]](function(){var a=o&&o.apply(this,arguments);a&&dn(a.promise)?a.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[n[0]+"With"](this,o?[a]:arguments)})}),a=null}).promise()},then:function(t,e,n){function p(o,e,t,n){return function(){var i=this,s=arguments,r=function(){var d,c;if(!(o<a)){if((d=t.apply(i,s))===e.promise())throw new TypeError("Thenable self-resolution");c=d&&("object"==typeof d||"function"==typeof d)&&d.then,dn(c)?n?c.call(d,p(a,e,q,n),p(a,e,I,n)):(a++,c.call(d,p(a,e,q,n),p(a,e,I,n),p(a,e,q,e.notifyWith))):(t!==q&&(i=void 0,s=[d]),(n||e.resolveWith)(i,s))}},d=n?r:function(){try{r()}catch(n){ln.Deferred.exceptionHook&&ln.Deferred.exceptionHook(n,d.stackTrace),o+1>=a&&(t!==I&&(i=void 0,s=[n]),e.rejectWith(i,s))}};o?d():(ln.Deferred.getStackHook&&(d.stackTrace=ln.Deferred.getStackHook()),Zt.setTimeout(d))}}var a=0;return ln.Deferred(function(a){d[0][3].add(p(0,a,dn(n)?n:q,a.notifyWith)),d[1][3].add(p(0,a,dn(t)?t:q)),d[2][3].add(p(0,a,dn(e)?e:I))}).promise()},promise:function(n){return null==n?t:ln.extend(n,t)}},l={};return ln.each(d,function(n,o){var i=o[2],a=o[5];t[o[1]]=i.add,a&&i.add(function(){e=a},d[3-n][2].disable,d[3-n][3].disable,d[0][2].lock,d[0][3].lock),i.add(o[3].fire),l[o[0]]=function(){return l[o[0]+"With"](this===l?void 0:this,arguments),this},l[o[0]+"With"]=i.fireWith}),t.promise(l),a&&a.call(l,l),l},when:function(s){var d=arguments.length,e=d,l=Array(e),r=an.call(arguments),i=ln.Deferred(),n=function(t){return function(e){l[t]=this,r[t]=1<arguments.length?an.call(arguments):e,--d||i.resolveWith(l,r)}};if(1>=d&&(_(s,i.done(n(e)).resolve,i.reject,!d),"pending"===i.state()||dn(r[e]&&r[e].then)))return i.then();for(;e--;)_(r[e],n(e),i.reject);return i.promise()}});var O=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;ln.Deferred.exceptionHook=function(n,e){Zt.console&&Zt.console.warn&&n&&O.test(n.name)&&Zt.console.warn("jQuery.Deferred exception: "+n.message,n.stack,e)},ln.readyException=function(t){Zt.setTimeout(function(){throw t})};var M=ln.Deferred();ln.fn.ready=function(t){return M.then(t).catch(function(t){ln.readyException(t)}),this},ln.extend({isReady:!1,readyWait:1,ready:function(t){(!0===t?--ln.readyWait:ln.isReady)||(ln.isReady=!0,!0!==t&&0<--ln.readyWait||M.resolveWith(y,[ln]))}}),ln.ready.then=M.then,"complete"!==y.readyState&&("loading"===y.readyState||y.documentElement.doScroll)?(y.addEventListener("DOMContentLoaded",W),Zt.addEventListener("load",W)):Zt.setTimeout(ln.ready);var B=function(d,e,t,n,r,i,o){var a=0,s=d.length,p=null==t;if("object"===w(t))for(a in r=!0,t)B(d,e,a,t[a],!0,i,o);else if(void 0!==n&&(r=!0,dn(n)||(o=!0),p&&(o?(e.call(d,n),e=null):(p=e,e=function(a,e,t){return p.call(ln(a),t)})),e))for(;a<s;a++)e(d[a],t,o?n:n.call(d[a],a,e(d[a],t)));return r?d:p?e.call(d):s?e(d[0],t):i},R=/^-ms-/,X=/-([a-z])/g,$=function(t){return 1===t.nodeType||9===t.nodeType||!+t.nodeType};Y.uid=1,Y.prototype={cache:function(n){var e=n[this.expando];return e||(e={},$(n)&&(n.nodeType?n[this.expando]=e:Object.defineProperty(n,this.expando,{value:e,configurable:!0}))),e},set:function(a,e,o){var n,s=this.cache(a);if("string"==typeof e)s[z(e)]=o;else for(n in e)s[z(n)]=e[n];return s},get:function(n,e){return void 0===e?this.cache(n):n[this.expando]&&n[this.expando][z(e)]},access:function(a,e,o){return void 0===e||e&&"string"==typeof e&&void 0===o?this.get(a,e):(this.set(a,e,o),void 0===o?e:o)},remove:function(a,e){var t,n=a[this.expando];if(void 0!==n){if(void 0!==e)for(t=(e=Array.isArray(e)?e.map(z):((e=z(e))in n)?[e]:e.match(P)||[]).length;t--;)delete n[e[t]];(void 0===e||ln.isEmptyObject(n))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(n){var e=n[this.expando];return void 0!==e&&!ln.isEmptyObject(e)}};var U=new Y,V=new Y,Q=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;ln.extend({hasData:function(t){return V.hasData(t)||U.hasData(t)},data:function(a,e,t){return V.access(a,e,t)},removeData:function(n,e){V.remove(n,e)},_data:function(a,e,t){return U.access(a,e,t)},_removeData:function(n,e){U.remove(n,e)}}),ln.fn.extend({data:function(s,d){var t,n,r,i=this[0],o=i&&i.attributes;if(void 0===s){if(this.length&&(r=V.get(i),1===i.nodeType&&!U.get(i,"hasDataAttrs"))){for(t=o.length;t--;)o[t]&&0===(n=o[t].name).indexOf("data-")&&(n=z(n.slice(5)),G(i,n,r[n]));U.set(i,"hasDataAttrs",!0)}return r}return"object"==typeof s?this.each(function(){V.set(this,s)}):B(this,function(e){var t;return i&&void 0===e?void 0!==(t=V.get(i,s))||void 0!==(t=G(i,s))?t:void 0:void this.each(function(){V.set(this,s,e)})},null,d,1<arguments.length,null,!0)},removeData:function(t){return this.each(function(){V.remove(this,t)})}}),ln.extend({queue:function(a,e,t){var n;if(a)return e=(e||"fx")+"queue",n=U.get(a,e),t&&(!n||Array.isArray(t)?n=U.access(a,e,ln.makeArray(t)):n.push(t)),n||[]},dequeue:function(a,e){e=e||"fx";var t=ln.queue(a,e),n=t.length,s=t.shift(),i=ln._queueHooks(a,e);"inprogress"===s&&(s=t.shift(),n--),s&&("fx"===e&&t.unshift("inprogress"),delete i.stop,s.call(a,function(){ln.dequeue(a,e)},i)),!n&&i&&i.empty.fire()},_queueHooks:function(a,e){var t=e+"queueHooks";return U.get(a,t)||U.access(a,t,{empty:ln.Callbacks("once memory").add(function(){U.remove(a,[e+"queue",t])})})}}),ln.fn.extend({queue:function(a,o){var t=2;return"string"!=typeof a&&(o=a,a="fx",t--),arguments.length<t?ln.queue(this[0],a):void 0===o?this:this.each(function(){var e=ln.queue(this,a,o);ln._queueHooks(this,a),"fx"===a&&"inprogress"!==e[0]&&ln.dequeue(this,a)})},dequeue:function(t){return this.each(function(){ln.dequeue(this,t)})},clearQueue:function(t){return this.queue(t||"fx",[])},promise:function(d,l){var t,n=1,r=ln.Deferred(),i=this,o=this.length,a=function(){--n||r.resolveWith(i,[i])};for("string"!=typeof d&&(l=d,d=void 0),d=d||"fx";o--;)(t=U.get(i[o],d+"queueHooks"))&&t.empty&&(n++,t.empty.add(a));return a(),r.promise(l)}});var Z=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ee=new RegExp("^(?:([+-])=|)("+Z+")([a-z%]*)$","i"),te=["Top","Right","Bottom","Left"],oe=y.documentElement,ae=function(t){return ln.contains(t.ownerDocument,t)},se={composed:!0};oe.getRootNode&&(ae=function(t){return ln.contains(t.ownerDocument,t)||t.getRootNode(se)===t.ownerDocument});var ie=function(n,e){return"none"===(n=e||n).style.display||""===n.style.display&&ae(n)&&"none"===ln.css(n,"display")},re={};ln.fn.extend({show:function(){return de(this,!0)},hide:function(){return de(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each(function(){ie(this)?ln(this).show():ln(this).hide()})}});var le,ue,he=/^(?:checkbox|radio)$/i,ge=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,fe=/^$|^module$|\/(?:java|ecma)script/i;le=y.createDocumentFragment().appendChild(y.createElement("div")),(ue=y.createElement("input")).setAttribute("type","radio"),ue.setAttribute("checked","checked"),ue.setAttribute("name","t"),le.appendChild(ue),rn.checkClone=le.cloneNode(!0).cloneNode(!0).lastChild.checked,le.innerHTML="<textarea>x</textarea>",rn.noCloneChecked=!!le.cloneNode(!0).lastChild.defaultValue,le.innerHTML="<option></option>",rn.option=!!le.lastChild;var me={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};me.tbody=me.tfoot=me.colgroup=me.caption=me.thead,me.th=me.td,rn.option||(me.optgroup=me.option=[1,"<select multiple='multiple'>","</select>"]);var ye=/<|&#?\w+;/,be=/^([^.]*)(?:\.(.+)|)/;ln.event={global:{},add:function(y,e,t,b,x){var v,o,a,s,u,l,c,f,d,T,h,C=U.get(y);if($(y))for(t.handler&&(t=(v=t).handler,x=v.selector),x&&ln.find.matchesSelector(oe,x),t.guid||(t.guid=ln.guid++),(s=C.events)||(s=C.events=Object.create(null)),(o=C.handle)||(o=C.handle=function(e){return void 0!==ln&&ln.event.triggered!==e.type?ln.event.dispatch.apply(y,arguments):void 0}),u=(e=(e||"").match(P)||[""]).length;u--;)d=h=(a=be.exec(e[u])||[])[1],T=(a[2]||"").split(".").sort(),d&&(c=ln.event.special[d]||{},d=(x?c.delegateType:c.bindType)||d,c=ln.event.special[d]||{},l=ln.extend({type:d,origType:h,data:b,handler:t,guid:t.guid,selector:x,needsContext:x&&ln.expr.match.needsContext.test(x),namespace:T.join(".")},v),(f=s[d])||((f=s[d]=[]).delegateCount=0,c.setup&&!1!==c.setup.call(y,b,T,o)||y.addEventListener&&y.addEventListener(d,o)),c.add&&(c.add.call(y,l),l.handler.guid||(l.handler.guid=t.guid)),x?f.splice(f.delegateCount++,0,l):f.push(l),ln.event.global[d]=!0)},remove:function(y,e,t,n,r){var b,o,a,s,u,l,c,f,d,p,h,g=U.hasData(y)&&U.get(y);if(g&&(s=g.events)){for(u=(e=(e||"").match(P)||[""]).length;u--;)if(d=h=(a=be.exec(e[u])||[])[1],p=(a[2]||"").split(".").sort(),d){for(c=ln.event.special[d]||{},f=s[d=(n?c.delegateType:c.bindType)||d]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),o=b=f.length;b--;)l=f[b],!r&&h!==l.origType||t&&t.guid!==l.guid||a&&!a.test(l.namespace)||n&&n!==l.selector&&("**"!==n||!l.selector)||(f.splice(b,1),l.selector&&f.delegateCount--,c.remove&&c.remove.call(y,l));o&&!f.length&&(c.teardown&&!1!==c.teardown.call(y,p,g.handle)||ln.removeEvent(y,d,g.handle),delete s[d])}else for(d in s)ln.event.remove(y,d+e[u],t,n,!0);ln.isEmptyObject(s)&&U.remove(y,"handle events")}},dispatch:function(d){var e,t,n,r,i,o,a=Array(arguments.length),s=ln.event.fix(d),p=(U.get(this,"events")||Object.create(null))[s.type]||[],l=ln.event.special[s.type]||{};for(a[0]=s,e=1;e<arguments.length;e++)a[e]=arguments[e];if(s.delegateTarget=this,!l.preDispatch||!1!==l.preDispatch.call(this,s)){for(o=ln.event.handlers.call(this,s,p),e=0;(r=o[e++])&&!s.isPropagationStopped();)for(s.currentTarget=r.elem,t=0;(i=r.handlers[t++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!1!==i.namespace&&!s.rnamespace.test(i.namespace)||(s.handleObj=i,s.data=i.data,void 0!==(n=((ln.event.special[i.origType]||{}).handle||i.handler).apply(r.elem,a))&&!1===(s.result=n)&&(s.preventDefault(),s.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,s),s.result}},handlers:function(d,e){var t,n,r,i,p,a=[],s=e.delegateCount,c=d.target;if(s&&c.nodeType&&!("click"===d.type&&1<=d.button))for(;c!==this;c=c.parentNode||this)if(1===c.nodeType&&("click"!==d.type||!0!==c.disabled)){for(i=[],p={},t=0;t<s;t++)void 0===p[r=(n=e[t]).selector+" "]&&(p[r]=n.needsContext?-1<ln(r,this).index(c):ln.find(r,this,null,[c]).length),p[r]&&i.push(n);i.length&&a.push({elem:c,handlers:i})}return c=this,s<e.length&&a.push({elem:c,handlers:e.slice(s)}),a},addProp:function(n,e){Object.defineProperty(ln.Event.prototype,n,{enumerable:!0,configurable:!0,get:dn(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[n]},set:function(e){Object.defineProperty(this,n,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(t){return t[ln.expando]?t:new ln.Event(t)},special:{load:{noBubble:!0},click:{setup:function(n){var e=this||n;return he.test(e.type)&&e.click&&S(e,"input")&&je(e,"click",Ce),!1},trigger:function(n){var e=this||n;return he.test(e.type)&&e.click&&S(e,"input")&&je(e,"click"),!0},_default:function(n){var e=n.target;return he.test(e.type)&&e.click&&S(e,"input")&&U.get(e,"click")||S(e,"a")}},beforeunload:{postDispatch:function(t){void 0!==t.result&&t.originalEvent&&(t.originalEvent.returnValue=t.result)}}}},ln.removeEvent=function(a,e,t){a.removeEventListener&&a.removeEventListener(e,t)},ln.Event=function(n,e){return this instanceof ln.Event?void(n&&n.type?(this.originalEvent=n,this.type=n.type,this.isDefaultPrevented=n.defaultPrevented||void 0===n.defaultPrevented&&!1===n.returnValue?Ce:we,this.target=n.target&&3===n.target.nodeType?n.target.parentNode:n.target,this.currentTarget=n.currentTarget,this.relatedTarget=n.relatedTarget):this.type=n,e&&ln.extend(this,e),this.timeStamp=n&&n.timeStamp||Date.now(),this[ln.expando]=!0):new ln.Event(n,e)},ln.Event.prototype={constructor:ln.Event,isDefaultPrevented:we,isPropagationStopped:we,isImmediatePropagationStopped:we,isSimulated:!1,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=Ce,t&&!this.isSimulated&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=Ce,t&&!this.isSimulated&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=Ce,t&&!this.isSimulated&&t.stopImmediatePropagation(),this.stopPropagation()}},ln.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},ln.event.addProp),ln.each({focus:"focusin",blur:"focusout"},function(n,e){ln.event.special[n]={setup:function(){return je(this,n,Se),!1},trigger:function(){return je(this,n),!0},_default:function(){return!0},delegateType:e}}),ln.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(n,a){ln.event.special[n]={delegateType:a,bindType:a,handle:function(t){var e,n=this,s=t.relatedTarget,i=t.handleObj;return s&&(s===n||ln.contains(n,s))||(t.type=i.origType,e=i.handler.apply(this,arguments),t.type=a),e}}}),ln.fn.extend({on:function(a,e,t,n){return ke(this,a,e,t,n)},one:function(a,e,t,n){return ke(this,a,e,t,n,1)},off:function(a,o,s){var n,r;if(a&&a.preventDefault&&a.handleObj)return n=a.handleObj,ln(a.delegateTarget).off(n.namespace?n.origType+"."+n.namespace:n.origType,n.selector,n.handler),this;if("object"==typeof a){for(r in a)this.off(r,o,a[r]);return this}return!1!==o&&"function"!=typeof o||(s=o,o=void 0),!1===s&&(s=we),this.each(function(){ln.event.remove(this,a,s,o)})}});var ve=/<script|<style|<link/i,Te=/checked\s*(?:[^=]|=\s*.checked.)/i,Ee=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;ln.extend({htmlPrefilter:function(t){return t},clone:function(d,e,t){var n,r,i,o,a=d.cloneNode(!0),s=ae(d);if(!(rn.noCloneChecked||1!==d.nodeType&&11!==d.nodeType||ln.isXMLDoc(d)))for(o=pe(a),n=0,r=(i=pe(d)).length;n<r;n++)Re(i[n],o[n]);if(e)if(t)for(i=i||pe(d),o=o||pe(a),n=0,r=i.length;n<r;n++)Pe(i[n],o[n]);else Pe(d,a);return 0<(o=pe(a,"script")).length&&ce(o,!s&&pe(d,"script")),a},cleanData:function(a){for(var e,t,n,s=ln.event.special,i=0;void 0!==(t=a[i]);i++)if($(t)){if(e=t[U.expando]){if(e.events)for(n in e.events)s[n]?ln.event.remove(t,n):ln.removeEvent(t,n,e.handle);t[U.expando]=void 0}t[V.expando]&&(t[V.expando]=void 0)}}}),ln.fn.extend({detach:function(t){return Me(this,t,!0)},remove:function(t){return Me(this,t)},text:function(t){return B(this,function(t){return void 0===t?ln.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)})},null,t,arguments.length)},append:function(){return Ie(this,arguments,function(t){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Ne(this,t).appendChild(t)})},prepend:function(){return Ie(this,arguments,function(n){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=Ne(this,n);e.insertBefore(n,e.firstChild)}})},before:function(){return Ie(this,arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this)})},after:function(){return Ie(this,arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)})},empty:function(){for(var n,e=0;null!=(n=this[e]);e++)1===n.nodeType&&(ln.cleanData(pe(n,!1)),n.textContent="");return this},clone:function(n,e){return n=null!=n&&n,e=null==e?n:e,this.map(function(){return ln.clone(this,n,e)})},html:function(t){return B(this,function(a){var o=this[0]||{},t=0,n=this.length;if(void 0===a&&1===o.nodeType)return o.innerHTML;if("string"==typeof a&&!ve.test(a)&&!me[(ge.exec(a)||["",""])[1].toLowerCase()]){a=ln.htmlPrefilter(a);try{for(;t<n;t++)1===(o=this[t]||{}).nodeType&&(ln.cleanData(pe(o,!1)),o.innerHTML=a);o=0}catch(t){}}o&&this.empty().append(a)},null,t,arguments.length)},replaceWith:function(){var a=[];return Ie(this,arguments,function(e){var t=this.parentNode;0>ln.inArray(this,a)&&(ln.cleanData(pe(this)),t&&t.replaceChild(e,this))},a)}}),ln.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(n,d){ln.fn[n]=function(t){for(var e,n=[],r=ln(t),i=r.length-1,o=0;o<=i;o++)e=o===i?this:this.clone(!0),ln(r[o])[d](e),s.apply(n,e.get());return this.pushStack(n)}});var De=new RegExp("^("+Z+")(?!px)[a-z%]+$","i"),Le=function(n){var e=n.ownerDocument.defaultView;return e&&e.opener||(e=Zt),e.getComputedStyle(n)},qe=function(a,e,t){var n,s,i={};for(s in e)i[s]=a.style[s],a.style[s]=e[s];for(s in n=t.call(a),e)a.style[s]=i[s];return n},Be=new RegExp(te.join("|"),"i");!function(){function r(){if(l){p.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",oe.appendChild(p).appendChild(l);var a=Zt.getComputedStyle(l);t="1%"!==a.top,s=12===d(a.marginLeft),l.style.right="60%",o=36===d(a.right),n=36===d(a.width),l.style.position="absolute",i=12===d(l.offsetWidth/3),oe.removeChild(p),l=null}}function d(t){return Math.round(parseFloat(t))}var t,n,i,o,a,s,p=y.createElement("div"),l=y.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",rn.clearCloneStyle="content-box"===l.style.backgroundClip,ln.extend(rn,{boxSizingReliable:function(){return r(),n},pixelBoxStyles:function(){return r(),o},pixelPosition:function(){return r(),t},reliableMarginLeft:function(){return r(),s},scrollboxSize:function(){return r(),i},reliableTrDimensions:function(){var o,e,t,n;return null==a&&(o=y.createElement("table"),e=y.createElement("tr"),t=y.createElement("div"),o.style.cssText="position:absolute;left:-11111px;border-collapse:separate",e.style.cssText="border:1px solid",e.style.height="1px",t.style.height="9px",t.style.display="block",oe.appendChild(o).appendChild(e).appendChild(t),n=Zt.getComputedStyle(e),a=parseInt(n.height,10)+parseInt(n.borderTopWidth,10)+parseInt(n.borderBottomWidth,10)===e.offsetHeight,oe.removeChild(o)),a}}))}();var We=["Webkit","Moz","ms"],Fe=y.createElement("div").style,Xe={},$e=/^(none|table(?!-c[ea]).+)/,Ve=/^--/,Ge={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};ln.extend({cssHooks:{opacity:{get:function(a,e){if(e){var t=_e(a,"opacity");return""===t?"1":t}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(d,e,t,p){if(d&&3!==d.nodeType&&8!==d.nodeType&&d.style){var r,i,o,a=z(e),s=Ve.test(e),c=d.style;if(s||(e=Ue(a)),o=ln.cssHooks[e]||ln.cssHooks[a],void 0===t)return o&&"get"in o&&void 0!==(r=o.get(d,!1,p))?r:c[e];"string"==(i=typeof t)&&(r=ee.exec(t))&&r[1]&&(t=J(d,e,r),i="number"),null!=t&&t==t&&("number"!==i||s||(t+=r&&r[3]||(ln.cssNumber[a]?"":"px")),rn.clearCloneStyle||""!==t||0!==e.indexOf("background")||(c[e]="inherit"),o&&"set"in o&&void 0===(t=o.set(d,t,p))||(s?c.setProperty(e,t):c[e]=t))}},css:function(d,e,t,n){var r,i,o,a=z(e);return Ve.test(e)||(e=Ue(a)),(o=ln.cssHooks[e]||ln.cssHooks[a])&&"get"in o&&(r=o.get(d,!0,t)),void 0===r&&(r=_e(d,e,n)),"normal"===r&&e in Qe&&(r=Qe[e]),""===t||t?(i=parseFloat(r),!0===t||isFinite(i)?i||0:r):r}}),ln.each(["height","width"],function(n,d){ln.cssHooks[d]={get:function(t,e,n){if(e)return!$e.test(ln.css(t,"display"))||t.getClientRects().length&&t.getBoundingClientRect().width?tt(t,d,n):qe(t,Ge,function(){return tt(t,d,n)})},set:function(t,e,n){var r,i=Le(t),o=!rn.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===ln.css(t,"boxSizing",!1,i),s=n?et(t,d,n,a,i):0;return a&&o&&(s-=$t(t["offset"+d[0].toUpperCase()+d.slice(1)]-parseFloat(i[d])-et(t,d,"border",!1,i)-.5)),s&&(r=ee.exec(e))&&"px"!==(r[3]||"px")&&(t.style[d]=e,e=ln.css(t,d)),Ye(0,e,s)}}}),ln.cssHooks.marginLeft=ze(rn.reliableMarginLeft,function(n,e){if(e)return(parseFloat(_e(n,"marginLeft"))||n.getBoundingClientRect().left-qe(n,{marginLeft:0},function(){return n.getBoundingClientRect().left}))+"px"}),ln.each({margin:"",padding:"",border:"Width"},function(a,e){ln.cssHooks[a+e]={expand:function(t){for(var s=0,r={},i="string"==typeof t?t.split(" "):[t];4>s;s++)r[a+te[s]+e]=i[s]||i[s-2]||i[0];return r}},"margin"!==a&&(ln.cssHooks[a+e].set=Ye)}),ln.fn.extend({css:function(n,e){return B(this,function(s,e,t){var n,r,i={},o=0;if(Array.isArray(e)){for(n=Le(s),r=e.length;o<r;o++)i[e[o]]=ln.css(s,e[o],!1,n);return i}return void 0===t?ln.css(s,e):ln.style(s,e,t)},n,e,1<arguments.length)}}),ln.Tween=nt,nt.prototype={constructor:nt,init:function(a,e,t,n,s,i){this.elem=a,this.prop=t,this.easing=s||ln.easing._default,this.options=e,this.start=this.now=this.cur(),this.end=n,this.unit=i||(ln.cssNumber[t]?"":"px")},cur:function(){var t=nt.propHooks[this.prop];return t&&t.get?t.get(this):nt.propHooks._default.get(this)},run:function(a){var e,t=nt.propHooks[this.prop];return this.pos=this.options.duration?e=ln.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):e=a,this.now=(this.end-this.start)*e+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),t&&t.set?t.set(this):nt.propHooks._default.set(this),this}},nt.prototype.init.prototype=nt.prototype,nt.propHooks={_default:{get:function(n){var e;return 1!==n.elem.nodeType||null!=n.elem[n.prop]&&null==n.elem.style[n.prop]?n.elem[n.prop]:(e=ln.css(n.elem,n.prop,""))&&"auto"!==e?e:0},set:function(t){ln.fx.step[t.prop]?ln.fx.step[t.prop](t):1===t.elem.nodeType&&(ln.cssHooks[t.prop]||null!=t.elem.style[Ue(t.prop)])?ln.style(t.elem,t.prop,t.now+t.unit):t.elem[t.prop]=t.now}}},nt.propHooks.scrollTop=nt.propHooks.scrollLeft={set:function(t){t.elem.nodeType&&t.elem.parentNode&&(t.elem[t.prop]=t.now)}},ln.easing={linear:function(t){return t},swing:function(t){return .5-Math.cos(t*Math.PI)/2},_default:"swing"},ln.fx=nt.prototype.init,ln.fx.step={};var Ke,Je,Ze=/^(?:toggle|show|hide)$/,at=/queueHooks$/;ln.Animation=ln.extend(ft,{tweeners:{"*":[function(a,e){var t=this.createTween(a,e);return J(t.elem,a,ee.exec(e),t),t}]},tweener:function(a,e){dn(a)?(e=a,a=["*"]):a=a.match(P);for(var t,n=0,o=a.length;n<o;n++)t=a[n],ft.tweeners[t]=ft.tweeners[t]||[],ft.tweeners[t].unshift(e)},prefilters:[function(y,e,t){var n,r,i,o,a,s,u,b,c="width"in e||"height"in e,f=this,d={},p=y.style,h=y.nodeType&&ie(y),x=U.get(y,"fxshow");for(n in t.queue||(null==(o=ln._queueHooks(y,"fx")).unqueued&&(o.unqueued=0,a=o.empty.fire,o.empty.fire=function(){o.unqueued||a()}),o.unqueued++,f.always(function(){f.always(function(){o.unqueued--,ln.queue(y,"fx").length||o.empty.fire()})})),e)if(r=e[n],Ze.test(r)){if(delete e[n],i=i||"toggle"===r,r===(h?"hide":"show")){if("show"!==r||!x||void 0===x[n])continue;h=!0}d[n]=x&&x[n]||ln.style(y,n)}if((s=!ln.isEmptyObject(e))||!ln.isEmptyObject(d))for(n in c&&1===y.nodeType&&(t.overflow=[p.overflow,p.overflowX,p.overflowY],null==(u=x&&x.display)&&(u=U.get(y,"display")),"none"===(b=ln.css(y,"display"))&&(u?b=u:(de([y],!0),u=y.style.display||u,b=ln.css(y,"display"),de([y]))),("inline"===b||"inline-block"===b&&null!=u)&&"none"===ln.css(y,"float")&&(s||(f.done(function(){p.display=u}),null==u&&(b=p.display,u="none"===b?"":b)),p.display="inline-block")),t.overflow&&(p.overflow="hidden",f.always(function(){p.overflow=t.overflow[0],p.overflowX=t.overflow[1],p.overflowY=t.overflow[2]})),s=!1,d)s||(x?"hidden"in x&&(h=x.hidden):x=U.access(y,"fxshow",{display:u}),i&&(x.hidden=!h),h&&de([y],!0),f.done(function(){for(n in h||de([y]),U.remove(y,"fxshow"),d)ln.style(y,n,d[n])})),s=ct(h?x[n]:0,n,f),n in x||(x[n]=s.start,h&&(s.end=s.start,s.start=0))}],prefilter:function(n,e){e?ft.prefilters.unshift(n):ft.prefilters.push(n)}}),ln.speed=function(a,o,t){var s=a&&"object"==typeof a?ln.extend({},a):{complete:t||!t&&o||dn(a)&&a,duration:a,easing:t&&o||o&&!dn(o)&&o};return ln.fx.off?s.duration=0:"number"!=typeof s.duration&&(s.duration in ln.fx.speeds?s.duration=ln.fx.speeds[s.duration]:s.duration=ln.fx.speeds._default),null!=s.queue&&!0!==s.queue||(s.queue="fx"),s.old=s.complete,s.complete=function(){dn(s.old)&&s.old.call(this),s.queue&&ln.dequeue(this,s.queue)},s},ln.fn.extend({fadeTo:function(a,e,o,n){return this.filter(ie).css("opacity",0).show().end().animate({opacity:e},a,o,n)},animate:function(s,e,t,n){var r=ln.isEmptyObject(s),i=ln.speed(e,t,n),o=function(){var e=ft(this,ln.extend({},s),i);(r||U.get(this,"finish"))&&e.stop(!0)};return o.finish=o,r||!1===i.queue?this.each(o):this.queue(i.queue,o)},stop:function(s,a,d){var n=function(n){var e=n.stop;delete n.stop,e(d)};return"string"!=typeof s&&(d=a,a=s,s=void 0),a&&this.queue(s||"fx",[]),this.each(function(){var e=!0,r=null!=s&&s+"queueHooks",i=ln.timers,o=U.get(this);if(r)o[r]&&o[r].stop&&n(o[r]);else for(r in o)o[r]&&o[r].stop&&at.test(r)&&n(o[r]);for(r=i.length;r--;)i[r].elem!==this||null!=s&&i[r].queue!==s||(i[r].anim.stop(d),e=!1,i.splice(r,1));!e&&d||ln.dequeue(this,s)})},finish:function(s){return!1!==s&&(s=s||"fx"),this.each(function(){var e,t=U.get(this),n=t[s+"queue"],r=t[s+"queueHooks"],i=ln.timers,o=n?n.length:0;for(t.finish=!0,ln.queue(this,s,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===s&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),ln.each(["toggle","show","hide"],function(a,o){var t=ln.fn[o];ln.fn[o]=function(n,a,s){return null==n||"boolean"==typeof n?t.apply(this,arguments):this.animate(lt(o,!0),n,a,s)}}),ln.each({slideDown:lt("show"),slideUp:lt("hide"),slideToggle:lt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(n,a){ln.fn[n]=function(t,e,n){return this.animate(a,t,e,n)}}),ln.timers=[],ln.fx.tick=function(){var a,e=0,t=ln.timers;for(Ke=Date.now();e<t.length;e++)(a=t[e])()||t[e]!==a||t.splice(e--,1);t.length||ln.fx.stop(),Ke=void 0},ln.fx.timer=function(t){ln.timers.push(t),ln.fx.start()},ln.fx.interval=13,ln.fx.start=function(){Je||(Je=!0,en())},ln.fx.stop=function(){Je=null},ln.fx.speeds={slow:600,fast:200,_default:400},ln.fn.delay=function(a,e){return a=ln.fx&&ln.fx.speeds[a]||a,e=e||"fx",this.queue(e,function(e,t){var n=Zt.setTimeout(e,a);t.stop=function(){Zt.clearTimeout(n)}})},function(){var n=y.createElement("input"),e=y.createElement("select").appendChild(y.createElement("option"));n.type="checkbox",rn.checkOn=""!==n.value,rn.optSelected=e.selected,(n=y.createElement("input")).value="t",n.type="radio",rn.radioValue="t"===n.value}();var ot,st=ln.expr.attrHandle;ln.fn.extend({attr:function(n,e){return B(this,ln.attr,n,e,1<arguments.length)},removeAttr:function(t){return this.each(function(){ln.removeAttr(this,t)})}}),ln.extend({attr:function(a,e,t){var n,s,i=a.nodeType;if(3!==i&&8!==i&&2!==i)return void 0===a.getAttribute?ln.prop(a,e,t):(1===i&&ln.isXMLDoc(a)||(s=ln.attrHooks[e.toLowerCase()]||(ln.expr.match.bool.test(e)?ot:void 0)),void 0===t?s&&"get"in s&&null!==(n=s.get(a,e))?n:null==(n=ln.find.attr(a,e))?void 0:n:null===t?void ln.removeAttr(a,e):s&&"set"in s&&void 0!==(n=s.set(a,t,e))?n:(a.setAttribute(e,t+""),t))},attrHooks:{type:{set:function(a,e){if(!rn.radioValue&&"radio"===e&&S(a,"input")){var t=a.value;return a.setAttribute("type",e),t&&(a.value=t),e}}}},removeAttr:function(a,e){var t,n=0,o=e&&e.match(P);if(o&&1===a.nodeType)for(;t=o[n++];)a.removeAttribute(t)}}),ot={set:function(a,e,t){return!1===e?ln.removeAttr(a,t):a.setAttribute(t,t),t}},ln.each(ln.expr.match.bool.source.match(/\w+/g),function(a,e){var s=st[e]||ln.find.attr;st[e]=function(n,e,t){var r,i,o=e.toLowerCase();return t||(i=st[o],st[o]=r,r=null==s(n,e,t)?null:o,st[o]=i),r}});var it=/^(?:input|select|textarea|button)$/i,pt=/^(?:a|area)$/i;ln.fn.extend({prop:function(n,e){return B(this,ln.prop,n,e,1<arguments.length)},removeProp:function(t){return this.each(function(){delete this[ln.propFix[t]||t]})}}),ln.extend({prop:function(a,e,t){var n,s,i=a.nodeType;if(3!==i&&8!==i&&2!==i)return 1===i&&ln.isXMLDoc(a)||(e=ln.propFix[e]||e,s=ln.propHooks[e]),void 0===t?s&&"get"in s&&null!==(n=s.get(a,e))?n:a[e]:s&&"set"in s&&void 0!==(n=s.set(a,t,e))?n:a[e]=t},propHooks:{tabIndex:{get:function(n){var e=ln.find.attr(n,"tabindex");return e?parseInt(e,10):it.test(n.nodeName)||pt.test(n.nodeName)&&n.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),rn.optSelected||(ln.propHooks.selected={get:function(n){var e=n.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null},set:function(n){var e=n.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),ln.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){ln.propFix[this.toLowerCase()]=this}),ln.fn.extend({addClass:function(d){var e,t,n,r,i,o,a,s=0;if(dn(d))return this.each(function(e){ln(this).addClass(d.call(this,e,vt(this)))});if((e=yt(d)).length)for(;t=this[s++];)if(r=vt(t),n=1===t.nodeType&&" "+dt(r)+" "){for(o=0;i=e[o++];)0>n.indexOf(" "+i+" ")&&(n+=i+" ");r!==(a=dt(n))&&t.setAttribute("class",a)}return this},removeClass:function(d){var e,t,n,r,i,o,a,s=0;if(dn(d))return this.each(function(e){ln(this).removeClass(d.call(this,e,vt(this)))});if(!arguments.length)return this.attr("class","");if((e=yt(d)).length)for(;t=this[s++];)if(r=vt(t),n=1===t.nodeType&&" "+dt(r)+" "){for(o=0;i=e[o++];)for(;-1<n.indexOf(" "+i+" ");)n=n.replace(" "+i+" "," ");r!==(a=dt(n))&&t.setAttribute("class",a)}return this},toggleClass:function(s,a){var d=typeof s,n="string"==d||Array.isArray(s);return"boolean"==typeof a&&n?a?this.addClass(s):this.removeClass(s):dn(s)?this.each(function(e){ln(this).toggleClass(s.call(this,e,vt(this),a),a)}):this.each(function(){var e,t,i,o;if(n)for(t=0,i=ln(this),o=yt(s);e=o[t++];)i.hasClass(e)?i.removeClass(e):i.addClass(e);else void 0!==s&&"boolean"!=d||((e=vt(this))&&U.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===s?"":U.get(this,"__className__")||""))})},hasClass:function(a){var e,t,n=0;for(e=" "+a+" ";t=this[n++];)if(1===t.nodeType&&-1<(" "+dt(vt(t))+" ").indexOf(e))return!0;return!1}});var ht=/\r/g;ln.fn.extend({val:function(a){var e,t,o,n=this[0];return arguments.length?(o=dn(a),this.each(function(t){var n;1===this.nodeType&&(null==(n=o?a.call(this,t,ln(this).val()):a)?n="":"number"==typeof n?n+="":Array.isArray(n)&&(n=ln.map(n,function(t){return null==t?"":t+""})),(e=ln.valHooks[this.type]||ln.valHooks[this.nodeName.toLowerCase()])&&"set"in e&&void 0!==e.set(this,n,"value")||(this.value=n))})):n?(e=ln.valHooks[n.type]||ln.valHooks[n.nodeName.toLowerCase()])&&"get"in e&&void 0!==(t=e.get(n,"value"))?t:"string"==typeof(t=n.value)?t.replace(ht,""):null==t?"":t:void 0}}),ln.extend({valHooks:{option:{get:function(n){var e=ln.find.attr(n,"value");return null==e?dt(ln.text(n)):e}},select:{get:function(d){var e,t,n,r=d.options,i=d.selectedIndex,o="select-one"===d.type,a=o?null:[],s=o?i+1:r.length;for(n=0>i?s:o?i:0;n<s;n++)if(((t=r[n]).selected||n===i)&&!t.disabled&&(!t.parentNode.disabled||!S(t.parentNode,"optgroup"))){if(e=ln(t).val(),o)return e;a.push(e)}return a},set:function(s,e){for(var t,n,r=s.options,i=ln.makeArray(e),o=r.length;o--;)((n=r[o]).selected=-1<ln.inArray(ln.valHooks.option.get(n),i))&&(t=!0);return t||(s.selectedIndex=-1),i}}}}),ln.each(["radio","checkbox"],function(){ln.valHooks[this]={set:function(n,e){if(Array.isArray(e))return n.checked=-1<ln.inArray(ln(n).val(),e)}},rn.checkOn||(ln.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})}),rn.focusin="onfocusin"in Zt;var gt=/^(?:focusinfocus|focusoutblur)$/,mt=function(t){t.stopPropagation()};ln.extend(ln.event,{trigger:function(r,p,t,n){var b,o,a,s,u,l,c,f,d=[t||y],h=sn.call(r,"type")?r.type:r,g=sn.call(r,"namespace")?r.namespace.split("."):[];if(o=f=a=t=t||y,3!==t.nodeType&&8!==t.nodeType&&!gt.test(h+ln.event.triggered)&&(-1<h.indexOf(".")&&(g=h.split("."),h=g.shift(),g.sort()),u=0>h.indexOf(":")&&"on"+h,(r=r[ln.expando]?r:new ln.Event(h,"object"==typeof r&&r)).isTrigger=n?2:3,r.namespace=g.join("."),r.rnamespace=r.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,r.result=void 0,r.target||(r.target=t),p=null==p?[r]:ln.makeArray(p,[r]),c=ln.event.special[h]||{},n||!c.trigger||!1!==c.trigger.apply(t,p))){if(!n&&!c.noBubble&&!v(t)){for(s=c.delegateType||h,gt.test(s+h)||(o=o.parentNode);o;o=o.parentNode)d.push(o),a=o;a===(t.ownerDocument||y)&&d.push(a.defaultView||a.parentWindow||Zt)}for(b=0;(o=d[b++])&&!r.isPropagationStopped();)f=o,r.type=1<b?s:c.bindType||h,(l=(U.get(o,"events")||Object.create(null))[r.type]&&U.get(o,"handle"))&&l.apply(o,p),(l=u&&o[u])&&l.apply&&$(o)&&(r.result=l.apply(o,p),!1===r.result&&r.preventDefault());return r.type=h,n||r.isDefaultPrevented()||c._default&&!1!==c._default.apply(d.pop(),p)||!$(t)||u&&dn(t[h])&&!v(t)&&((a=t[u])&&(t[u]=null),ln.event.triggered=h,r.isPropagationStopped()&&f.addEventListener(h,mt),t[h](),r.isPropagationStopped()&&f.removeEventListener(h,mt),ln.event.triggered=void 0,a&&(t[u]=a)),r.result}},simulate:function(a,o,t){var n=ln.extend(new ln.Event,t,{type:a,isSimulated:!0});ln.event.trigger(n,null,o)}}),ln.fn.extend({trigger:function(n,e){return this.each(function(){ln.event.trigger(n,e,this)})},triggerHandler:function(a,e){var t=this[0];if(t)return ln.event.trigger(a,e,t,!0)}}),rn.focusin||ln.each({focus:"focusin",blur:"focusout"},function(a,o){var e=function(t){ln.event.simulate(o,t.target,ln.event.fix(t))};ln.event.special[o]={setup:function(){var t=this.ownerDocument||this.document||this,n=U.access(t,o);n||t.addEventListener(a,e,!0),U.access(t,o,(n||0)+1)},teardown:function(){var t=this.ownerDocument||this.document||this,n=U.access(t,o)-1;n?U.access(t,o,n):(t.removeEventListener(a,e,!0),U.remove(t,o))}}});var xt=Zt.location,Tt={guid:Date.now()},Ct=/\?/;ln.parseXML=function(a){var o,t;if(!a||"string"!=typeof a)return null;try{o=new Zt.DOMParser().parseFromString(a,"text/xml")}catch(t){}return t=o&&o.getElementsByTagName("parsererror")[0],o&&!t||ln.error("Invalid XML: "+(t?ln.map(t.childNodes,function(t){return t.textContent}).join("\n"):a)),o};var wt=/\[\]$/,St=/\r?\n/g,Et=/^(?:submit|button|image|reset|file)$/i,kt=/^(?:input|select|textarea|keygen)/i;ln.param=function(a,e){var t,o=[],n=function(a,e){var t=dn(e)?e():e;o[o.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==t?"":t)};if(null==a)return"";if(Array.isArray(a)||a.jquery&&!ln.isPlainObject(a))ln.each(a,function(){n(this.name,this.value)});else for(t in a)bt(t,a[t],e,n);return o.join("&")},ln.fn.extend({serialize:function(){return ln.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var t=ln.prop(this,"elements");return t?ln.makeArray(t):this}).filter(function(){var t=this.type;return this.name&&!ln(this).is(":disabled")&&kt.test(this.nodeName)&&!Et.test(t)&&(this.checked||!he.test(t))}).map(function(a,o){var e=ln(this).val();return null==e?null:Array.isArray(e)?ln.map(e,function(t){return{name:o.name,value:t.replace(St,"\r\n")}}):{name:o.name,value:e.replace(St,"\r\n")}}).get()}});var Nt=/%20/g,At=/#.*$/,jt=/([?&])_=[^&]*/,Lt=/^(.*?):[ \t]*([^\r\n]*)$/gm,qt=/^(?:GET|HEAD)$/,Ht=/^\/\//,Pt={},Ot={},It="*/".concat("*"),Mt=y.createElement("a");Mt.href=xt.href,ln.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:xt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(xt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":It,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":ln.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(n,e){return e?Bt(Bt(n,ln.ajaxSettings),e):Bt(ln.ajaxSettings,n)},ajaxPrefilter:Dt(Pt),ajaxTransport:Dt(Ot),ajax:function(r,b){function E(o,r,t,a){var c,u,d,y,b,x=r;s||(s=!0,k&&Zt.clearTimeout(k),S=void 0,i=a||"",A.readyState=0<o?4:0,c=200<=o&&300>o||304===o,t&&(y=function(d,e,t){for(var n,r,i,o,a=d.contents,s=d.dataTypes;"*"===s[0];)s.shift(),void 0===n&&(n=d.mimeType||e.getResponseHeader("Content-Type"));if(n)for(r in a)if(a[r]&&a[r].test(n)){s.unshift(r);break}if(s[0]in t)i=s[0];else{for(r in t){if(!s[0]||d.converters[r+" "+s[0]]){i=r;break}o||(o=r)}i=i||o}return i?(i!==s[0]&&s.unshift(i),t[i]):void 0}(N,A,t)),!c&&-1<ln.inArray("script",N.dataTypes)&&0>ln.inArray("json",N.dataTypes)&&(N.converters["text script"]=function(){}),y=function(d,e,p,n){var r,i,o,a,s,h={},l=d.dataTypes.slice();if(l[1])for(o in d.converters)h[o.toLowerCase()]=d.converters[o];for(i=l.shift();i;)if(d.responseFields[i]&&(p[d.responseFields[i]]=e),!s&&n&&d.dataFilter&&(e=d.dataFilter(e,d.dataType)),s=i,i=l.shift())if("*"===i)i=s;else if("*"!==s&&s!==i){if(!(o=h[s+" "+i]||h["* "+i]))for(r in h)if((a=r.split(" "))[1]===i&&(o=h[s+" "+a[0]]||h["* "+a[0]])){!0===o?o=h[r]:!0!==h[r]&&(i=a[0],l.unshift(a[1]));break}if(!0!==o)if(o&&d.throws)e=o(e);else try{e=o(e)}catch(t){return{state:"parsererror",error:o?t:"No conversion from "+s+" to "+i}}}return{state:"success",data:e}}(N,y,A,c),c?(N.ifModified&&((b=A.getResponseHeader("Last-Modified"))&&(ln.lastModified[n]=b),(b=A.getResponseHeader("etag"))&&(ln.etag[n]=b)),204===o||"HEAD"===N.type?x="nocontent":304===o?x="notmodified":(x=y.state,u=y.data,c=!(d=y.error))):(d=x,!o&&x||(x="error",0>o&&(o=0))),A.status=o,A.statusText=(r||x)+"",c?g.resolveWith(p,[u,x,A]):g.rejectWith(p,[A,x,d]),A.statusCode(v),v=void 0,l&&h.trigger(c?"ajaxSuccess":"ajaxError",[A,N,c?u:d]),m.fireWith(p,[A,x]),l&&(h.trigger("ajaxComplete",[A,N]),--ln.active||ln.event.trigger("ajaxStop")))}"object"==typeof r&&(b=r,r=void 0),b=b||{};var S,n,i,o,k,t,s,l,c,u,N=ln.ajaxSetup({},b),p=N.context||N,h=N.context&&(p.nodeType||p.jquery)?ln(p):ln.event,g=ln.Deferred(),m=ln.Callbacks("once memory"),v=N.statusCode||{},d={},f={},x="canceled",A={readyState:0,getResponseHeader:function(n){var e;if(s){if(!o)for(o={};e=Lt.exec(i);)o[e[1].toLowerCase()+" "]=(o[e[1].toLowerCase()+" "]||[]).concat(e[2]);e=o[n.toLowerCase()+" "]}return null==e?null:e.join(", ")},getAllResponseHeaders:function(){return s?i:null},setRequestHeader:function(n,e){return null==s&&(n=f[n.toLowerCase()]=f[n.toLowerCase()]||n,d[n]=e),this},overrideMimeType:function(t){return null==s&&(N.mimeType=t),this},statusCode:function(n){if(n)if(s)A.always(n[A.status]);else for(var e in n)v[e]=[v[e],n[e]];return this},abort:function(n){var e=n||x;return S&&S.abort(e),E(0,e),this}};if(g.promise(A),N.url=((r||N.url||xt.href)+"").replace(Ht,xt.protocol+"//"),N.type=b.method||b.type||N.method||N.type,N.dataTypes=(N.dataType||"*").toLowerCase().match(P)||[""],null==N.crossDomain){t=y.createElement("a");try{t.href=N.url,t.href=t.href,N.crossDomain=Mt.protocol+"//"+Mt.host!=t.protocol+"//"+t.host}catch(t){N.crossDomain=!0}}if(N.data&&N.processData&&"string"!=typeof N.data&&(N.data=ln.param(N.data,N.traditional)),Ft(Pt,N,b,A),s)return A;for(c in(l=ln.event&&N.global)&&0==ln.active++&&ln.event.trigger("ajaxStart"),N.type=N.type.toUpperCase(),N.hasContent=!qt.test(N.type),n=N.url.replace(At,""),N.hasContent?N.data&&N.processData&&0===(N.contentType||"").indexOf("application/x-www-form-urlencoded")&&(N.data=N.data.replace(Nt,"+")):(u=N.url.slice(n.length),N.data&&(N.processData||"string"==typeof N.data)&&(n+=(Ct.test(n)?"&":"?")+N.data,delete N.data),!1===N.cache&&(n=n.replace(jt,"$1"),u=(Ct.test(n)?"&":"?")+"_="+Tt.guid++ +u),N.url=n+u),N.ifModified&&(ln.lastModified[n]&&A.setRequestHeader("If-Modified-Since",ln.lastModified[n]),ln.etag[n]&&A.setRequestHeader("If-None-Match",ln.etag[n])),(N.data&&N.hasContent&&!1!==N.contentType||b.contentType)&&A.setRequestHeader("Content-Type",N.contentType),A.setRequestHeader("Accept",N.dataTypes[0]&&N.accepts[N.dataTypes[0]]?N.accepts[N.dataTypes[0]]+("*"===N.dataTypes[0]?"":", "+It+"; q=0.01"):N.accepts["*"]),N.headers)A.setRequestHeader(c,N.headers[c]);if(N.beforeSend&&(!1===N.beforeSend.call(p,A,N)||s))return A.abort();if(x="abort",m.add(N.complete),A.done(N.success),A.fail(N.error),S=Ft(Ot,N,b,A)){if(A.readyState=1,l&&h.trigger("ajaxSend",[A,N]),s)return A;N.async&&0<N.timeout&&(k=Zt.setTimeout(function(){A.abort("timeout")},N.timeout));try{s=!1,S.send(d,E)}catch(t){if(s)throw t;E(-1,t)}}else E(-1,"No Transport");return A},getJSON:function(a,e,t){return ln.get(a,e,t,"json")},getScript:function(n,e){return ln.get(n,void 0,e,"script")}}),ln.each(["get","post"],function(n,a){ln[a]=function(o,s,d,l){return dn(s)&&(l=l||d,d=s,s=void 0),ln.ajax(ln.extend({url:o,type:a,dataType:l,data:s,success:d},ln.isPlainObject(o)&&o))}}),ln.ajaxPrefilter(function(n){for(var e in n.headers)"content-type"===e.toLowerCase()&&(n.contentType=n.headers[e]||"")}),ln._evalUrl=function(a,o,t){return ln.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(n){ln.globalEval(n,o,t)}})},ln.fn.extend({wrapAll:function(n){var e;return this[0]&&(dn(n)&&(n=n.call(this[0])),e=ln(n,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map(function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t}).append(this)),this},wrapInner:function(a){return dn(a)?this.each(function(e){ln(this).wrapInner(a.call(this,e))}):this.each(function(){var e=ln(this),t=e.contents();t.length?t.wrapAll(a):e.append(a)})},wrap:function(a){var e=dn(a);return this.each(function(t){ln(this).wrapAll(e?a.call(this,t):a)})},unwrap:function(t){return this.parent(t).not("body").each(function(){ln(this).replaceWith(this.childNodes)}),this}}),ln.expr.pseudos.hidden=function(t){return!ln.expr.pseudos.visible(t)},ln.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},ln.ajaxSettings.xhr=function(){try{return new Zt.XMLHttpRequest}catch(t){}};var Rt={0:200,1223:204},Wt=ln.ajaxSettings.xhr();rn.cors=!!Wt&&"withCredentials"in Wt,rn.ajax=Wt=!!Wt,ln.ajaxTransport(function(r){var d,t;if(rn.cors||Wt&&!r.crossDomain)return{send:function(e,n){var o,a=r.xhr();if(a.open(r.type,r.url,r.async,r.username,r.password),r.xhrFields)for(o in r.xhrFields)a[o]=r.xhrFields[o];for(o in r.mimeType&&a.overrideMimeType&&a.overrideMimeType(r.mimeType),r.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)a.setRequestHeader(o,e[o]);d=function(o){return function(){d&&(d=t=a.onload=a.onerror=a.onabort=a.ontimeout=a.onreadystatechange=null,"abort"===o?a.abort():"error"===o?"number"==typeof a.status?n(a.status,a.statusText):n(0,"error"):n(Rt[a.status]||a.status,a.statusText,"text"!==(a.responseType||"text")||"string"!=typeof a.responseText?{binary:a.response}:{text:a.responseText},a.getAllResponseHeaders()))}},a.onload=d(),t=a.onerror=a.ontimeout=d("error"),void 0===a.onabort?a.onreadystatechange=function(){4===a.readyState&&Zt.setTimeout(function(){d&&t()})}:a.onabort=t,d=d("abort");try{a.send(r.hasContent&&r.data||null)}catch(t){if(d)throw t}},abort:function(){d&&d()}}}),ln.ajaxPrefilter(function(t){t.crossDomain&&(t.contents.script=!1)}),ln.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(t){return ln.globalEval(t),t}}}),ln.ajaxPrefilter("script",function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET")}),ln.ajaxTransport("script",function(a){var o,t;if(a.crossDomain||a.scriptAttrs)return{send:function(e,n){o=ln("<script>").attr(a.scriptAttrs||{}).prop({charset:a.scriptCharset,src:a.url}).on("load error",t=function(a){o.remove(),t=null,a&&n("error"===a.type?404:200,a.type)}),y.head.appendChild(o[0])},abort:function(){t&&t()}}});var zt,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;ln.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var t=Xt.pop()||ln.expando+"_"+Tt.guid++;return this[t]=!0,t}}),ln.ajaxPrefilter("json jsonp",function(r,e,t){var n,i,o,a=!1!==r.jsonp&&(Vt.test(r.url)?"url":"string"==typeof r.data&&0===(r.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(r.data)&&"data");if(a||"jsonp"===r.dataTypes[0])return n=r.jsonpCallback=dn(r.jsonpCallback)?r.jsonpCallback():r.jsonpCallback,a?r[a]=r[a].replace(Vt,"$1"+n):!1!==r.jsonp&&(r.url+=(Ct.test(r.url)?"&":"?")+r.jsonp+"="+n),r.converters["script json"]=function(){return o||ln.error(n+" was not called"),o[0]},r.dataTypes[0]="json",i=Zt[n],Zt[n]=function(){o=arguments},t.always(function(){void 0===i?ln(Zt).removeProp(n):Zt[n]=i,r[n]&&(r.jsonpCallback=e.jsonpCallback,Xt.push(n)),o&&dn(i)&&i(o[0]),o=i=void 0}),"script"}),rn.createHTMLDocument=((zt=y.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===zt.childNodes.length),ln.parseHTML=function(a,s,d){return"string"==typeof a?("boolean"==typeof s&&(d=s,s=!1),s||(rn.createHTMLDocument?((l=(s=y.implementation.createHTMLDocument("")).createElement("base")).href=y.location.href,s.head.appendChild(l)):s=y),i=!d&&[],(r=N.exec(a))?[s.createElement(r[1])]:(r=xe([a],s,i),i&&i.length&&ln(i).remove(),ln.merge([],r.childNodes))):[];var l,r,i},ln.fn.load=function(d,l,p){var n,r,i,o=this,a=d.indexOf(" ");return-1<a&&(n=dt(d.slice(a)),d=d.slice(0,a)),dn(l)?(p=l,l=void 0):l&&"object"==typeof l&&(r="POST"),0<o.length&&ln.ajax({url:d,type:r||"GET",dataType:"html",data:l}).done(function(t){i=arguments,o.html(n?ln("<div>").append(ln.parseHTML(t)).find(n):t)}).always(p&&function(n,e){o.each(function(){p.apply(this,i||[n.responseText,e,n])})}),this},ln.expr.pseudos.animated=function(n){return ln.grep(ln.timers,function(e){return n===e.elem}).length},ln.offset={setOffset:function(d,e,t){var n,r,i,o,a,s,p=ln.css(d,"position"),l=ln(d),c={};"static"===p&&(d.style.position="relative"),a=l.offset(),i=ln.css(d,"top"),s=ln.css(d,"left"),("absolute"===p||"fixed"===p)&&-1<(i+s).indexOf("auto")?(o=(n=l.position()).top,r=n.left):(o=parseFloat(i)||0,r=parseFloat(s)||0),dn(e)&&(e=e.call(d,t,ln.extend({},a))),null!=e.top&&(c.top=e.top-a.top+o),null!=e.left&&(c.left=e.left-a.left+r),"using"in e?e.using.call(d,c):l.css(c)}},ln.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(e){ln.offset.setOffset(this,a,e)});var e,t,n=this[0];return n?n.getClientRects().length?(e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView,{top:e.top+t.pageYOffset,left:e.left+t.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var a,e,t,n=this[0],o={top:0,left:0};if("fixed"===ln.css(n,"position"))e=n.getBoundingClientRect();else{for(e=this.offset(),t=n.ownerDocument,a=n.offsetParent||t.documentElement;a&&(a===t.body||a===t.documentElement)&&"static"===ln.css(a,"position");)a=a.parentNode;a&&a!==n&&1===a.nodeType&&((o=ln(a).offset()).top+=ln.css(a,"borderTopWidth",!0),o.left+=ln.css(a,"borderLeftWidth",!0))}return{top:e.top-o.top-ln.css(n,"marginTop",!0),left:e.left-o.left-ln.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent;t&&"static"===ln.css(t,"position");)t=t.offsetParent;return t||oe})}}),ln.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,s){var t="pageYOffset"===s;ln.fn[a]=function(e){return B(this,function(n,e,a){var i;return(v(n)?i=n:9===n.nodeType&&(i=n.defaultView),void 0===a)?i?i[s]:n[e]:void(i?i.scrollTo(t?i.pageXOffset:a,t?a:i.pageYOffset):n[e]=a)},a,e,arguments.length)}}),ln.each(["top","left"],function(n,a){ln.cssHooks[a]=ze(rn.pixelPosition,function(t,e){if(e)return e=_e(t,a),De.test(e)?ln(t).position()[a]+"px":e})}),ln.each({Height:"height",Width:"width"},function(a,e){ln.each({padding:"inner"+a,content:e,"":"outer"+a},function(t,d){ln.fn[d]=function(n,r){var o=arguments.length&&(t||"boolean"!=typeof n),l=t||(!0===n||!0===r?"margin":"border");return B(this,function(e,t,n){var s;return v(e)?0===d.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(s=e.documentElement,tn(e.body["scroll"+a],s["scroll"+a],e.body["offset"+a],s["offset"+a],s["client"+a])):void 0===n?ln.css(e,t,l):ln.style(e,t,n,l)},e,o?n:void 0,o)}})}),ln.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(n,a){ln.fn[a]=function(t){return this.on(a,t)}}),ln.fn.extend({bind:function(a,e,t){return this.on(a,null,e,t)},unbind:function(n,e){return this.off(n,null,e)},delegate:function(a,e,t,n){return this.on(e,a,t,n)},undelegate:function(a,e,t){return 1===arguments.length?this.off(a,"**"):this.off(e,a||"**",t)},hover:function(n,e){return this.mouseenter(n).mouseleave(e||n)}}),ln.each(["blur","focus","focusin","focusout","resize","scroll","click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","change","select","submit","keydown","keypress","keyup","contextmenu"],function(n,a){ln.fn[a]=function(t,e){return 0<arguments.length?this.on(a,null,t,e):this.trigger(a)}});var Gt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;ln.proxy=function(a,e){var o,n,s;if("string"==typeof e&&(o=a[e],e=a,a=o),dn(a))return n=an.call(arguments,2),s=function(){return a.apply(e||this,n.concat(an.call(arguments)))},s.guid=a.guid=a.guid||ln.guid++,s},ln.holdReady=function(t){t?ln.readyWait++:ln.ready(!0)},ln.isArray=Array.isArray,ln.parseJSON=JSON.parse,ln.nodeName=S,ln.isFunction=dn,ln.isWindow=v,ln.camelCase=z,ln.type=w,ln.now=Date.now,ln.isNumeric=function(n){var e=ln.type(n);return("number"===e||"string"===e)&&!isNaN(n-parseFloat(n))},ln.trim=function(t){return null==t?"":(t+"").replace(Gt,"")},void 0===(t=function(){return ln}.apply(e,[]))||(Kt.exports=t);var Yt=Zt.jQuery,Qt=Zt.$;return ln.noConflict=function(t){return Zt.$===ln&&(Zt.$=Qt),t&&Zt.jQuery===ln&&(Zt.jQuery=Yt),ln},void 0===n&&(Zt.jQuery=Zt.$=ln),ln})}},e={};(()=>{"use strict";function N(t){return"string"==typeof t?document.getElementById(t):t}function A(e){return!!(e=N(e))&&"none"===getComputedStyle(e).display}function e(t){return!A(t)}function t(t){return!!t}function i(e){return /^\s*$/.test(N(e).innerHTML)}function n(n){var e=n.style;e.height=e.maxHeight=e.minHeight="auto",e.display="none"}function a(n){var e=n.style;e.height=e.maxHeight=e.minHeight="auto",e.display="none",[].forEach.call(n.children,a)}function o(t){t.style.height="1px",t.style["min-height"]="1px",t.style["max-height"]="1px",[].forEach.call(t.children,o)}function s(n){var e=n.style;e.height=e.maxHeight=e.minHeight="auto",e.removeProperty("display")}function r(a,e){var t;return function(){return a&&(t=a.call(e||this,arguments),a=null),t}}function l(n){var e=document.createElement("script");e.src=n,document.body.appendChild(e)}function c(n,a){return n.push=function(t){return a(),delete this.push,this.push(t)},n}function j(){return"undefined"!=typeof googletag&&!!googletag.apiReady}function v(){var t;j()||(window.googletag={cmd:(t=g,c([],t))})}function u(a){var e=a.split("_")[0],t=x.ids[e],o=x.slots[t];return"function"==typeof o&&(o=o(e)),{path:"/248424177/"+b+"/"+t+"/"+m,sizes:o,zone:t}}function d(l){try{Array.isArray(clc.dfp.slotsRenderedEvents)||(clc.dfp.slotsRenderedEvents=[]),clc.dfp.slotsRenderedEvents.push(l);var e=l.slot.getSlotElementId(),t=[];e||t.push("id=0");var p=document.getElementById(e);if(e&&!p?t.push("el=0"):p.hasAttribute("data-clc-stalled")&&t.push("st=1"),0!==t.length)return void T(t.join("&"));var g=u(e),i=(g.path,g.sizes,g.zone);if(clc.collapse&&clc.collapse[i]&&l.isEmpty)return p.id,a(p),void p.setAttribute("data-clc-ready","true");p.id,l.lineItemId;var m=-1!==y.dh.indexOf(l.lineItemId),c=(y.cpa_liid&&0<y.cpa_liid.length||y.cpa_cid&&0<y.cpa_cid.length)&&(y.cpa_liid&&-1!==y.cpa_liid.indexOf(l.lineItemId)||y.cpa_cid&&-1!==y.cpa_cid.indexOf(l.creativeId));if(m||c){o(p),c&&y.cpas&&p.setAttribute("data-clc-cpa-reserved","true");var f=p.parentElement;c&&f.classList.contains("js-zone-container")&&f.querySelectorAll(".js-report-ad-button-container")[0].remove()}else if(l.lineItemId){if(p.setAttribute("data-clc-prefilled","true"),(f=p.parentElement).classList.contains("js-zone-container")){switch(n(f),p.id,f.querySelectorAll(".js-report-ad-button-container")[0].style.height="24px",e){case"dfp-tlb":0===y.tlb_position?f.classList.add("mb8"):f.classList.add("my8");break;case"dfp-tag":f.classList.add("mb8");break;case"dfp-mlb":case"dfp-smlb":case"dfp-bmlb":f.classList.add("my8");break;case"dfp-isb":f.classList.add("mt24");break;case"dfp-m-aq":f.classList.add("my12"),f.classList.add("mx-auto");}s(f),s(p)}else s(p);"dfp-msb"==e&&a(document.getElementById("hireme"))}p.setAttribute("data-clc-ready","true")}catch(t){var d=document.querySelector("#dfp-tsb, #dfp-isb, #clc-tsb");d&&d.setAttribute("data-clc-ready","true"),T("e=1")}}function f(d,e){"dfp-isb"===d&&e.pubads().setTargeting("Sidebar",["Inline"]),"dfp-tsb"===d&&e.pubads().setTargeting("Sidebar",["Right"]);var t=u(d),n=t.path,r=t.sizes;t.zone,JSON.stringify(r);var i=e.defineSlot(n,r,d);i.addService(e.pubads());var o=d.split("_");if("clc-cpa"==o[0]&&o[1]){var a=o[1];i.setTargeting("talent-company-id",a)}}window.clc=window.clc||{};var y=function(a,e){for(var t in e)a[t]=e[t];return a}({"lib":"https://cdn.sstatic.net/clc/clc.min.js?v=928e9353f0e8","style":"https://cdn.sstatic.net/clc/styles/clc.min.css?v=dd7c0645af5d","u":"https://clc.stackoverflow.com/markup.js","wa":true,"kt":2000,"tto":true,"h":"clc.stackoverflow.com","allowed":"^(((talent\\.)?stackoverflow)|(blog\\.codinghorror)|(serverfault|askubuntu)|([^\\.]+\\.stackexchange))\\.com$","wv":true,"al":false,"dh":[5171832659],"abd":true,"cpa_liid":[5882654614],"cpa_cid":[138377597667],"cpas":true,"dp":false},clc.options||{}),p=r(function(){l(y.lib)});window.clc=window.clc||{},clc.cmd=clc.cmd||[];var h=clc.cmd;Array.isArray(clc.cmd)&&(0<clc.cmd.length?p():c(clc.cmd,p));var g=r(function(){y.targeting_consent||void 0===y.targeting_consent?l("https://securepubads.g.doubleclick.net/tag/js/gpt.js"):l("https://pagead2.googlesyndication.com/tag/js/gpt.js")}),m=/^\/tags\//.test(location.pathname)||/^\/questions\/tagged\//.test(location.pathname)?"tag-pages":/^\/$/.test(location.pathname)||/^\/home/.test(location.pathname)?"home-page":"question-pages",b=location.hostname,x={slots:{lb:[[728,90]],mlb:[[728,90]],smlb:[[728,90]],bmlb:[[728,90]],sb:function(t){return"dfp-tsb"===t?[[300,250],[300,600]]:[[300,250]]},"tag-sponsorship":[[730,135]],"mobile-below-question":[[320,50],[300,250]],msb:[[300,250],[300,600]],"talent-conversion-tracking":[[1,1]]},ids:{"dfp-tlb":"lb","dfp-mlb":"mlb","dfp-smlb":"smlb","dfp-bmlb":"bmlb","dfp-tsb":"sb","dfp-isb":"sb","dfp-tag":"tag-sponsorship","dfp-msb":"msb","dfp-m-aq":"mobile-below-question","clc-tlb":"lb","clc-mlb":"mlb","clc-tsb":"sb","clc-cpa":"talent-conversion-tracking"}},T=function(t){new Image().src="https://"+y.h+"/stalled.gif?"+t};k(291),window.clc=window.clc||{},clc.options=y,clc.cmd=h,clc.dfp={load:function o(s){void 0===s&&(s=Object.keys(x.ids).filter(function(t){return"clc-cpa"!=t}));var r=0===y.tlb_position?["dfp-mlb","dfp-smlb"]:["dfp-mlb","dfp-smlb","dfp-tlb"];if(!j())return v(),void googletag.cmd.push(function(){return o(s)});var l=function(o){var n=o.map(N).filter(t);return{eligible:n.filter(i).filter(e),ineligible:n.filter(A)}}(s),p=l.eligible,c=l.ineligible;if(p.forEach(function(t){n(t)}),c.forEach(a),0!==p.length){var u;y.abd&&((u=document.createElement("div")).className="adsbox",u.id="clc-abd",u.style.position="absolute",u.style.pointerEvents="none",u.innerHTML="&nbsp;",document.body.appendChild(u));var h=googletag.pubads().getSlots().filter(function(t){return 0<=s.indexOf(t.getSlotElementId())});googletag.destroySlots(h),y.sf&&(googletag.pubads().setForceSafeFrame(!0),googletag.pubads().setSafeFrameConfig({allowOverlayExpansion:!0,allowPushExpansion:!0,sandbox:!0})),void 0!==y.targeting_consent&&(y.targeting_consent,googletag.pubads().setRequestNonPersonalizedAds(y.targeting_consent?0:1),y.targeting_consent||googletag.pubads().setPrivacySettings({limitedAds:!0})),y.ll||googletag.pubads().enableSingleRequest(),window.clc=window.clc||{},clc.sreEvent||(googletag.pubads().addEventListener("slotRenderEnded",d),clc.sreEvent=!0),function(a){var e=window.clc&&clc.dfp&&clc.dfp.targeting||{};"SystemDefault"===e.ProductVariant&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?e.ProductVariant="Dark":e.ProductVariant="Light"),Object.keys(e).forEach(function(t){e[t],a.pubads().setTargeting(t,e[t])})}(googletag);var g=p.filter(function(t){return!y.ll||0>r.indexOf(t.id)}),m=p.filter(function(t){return!!y.ll&&0<=r.indexOf(t.id)});g.forEach(function(t){t.id,f(t.id,googletag),t.setAttribute("data-dfp-zone","true")}),googletag.enableServices(),g.forEach(function(t){t.id,googletag.cmd.push(function(){googletag.display(t.id)})}),y.ll&&(googletag.pubads().enableLazyLoad({fetchMarginPercent:0,renderMarginPercent:0}),m.forEach(function(t){t.id,f(t.id,googletag),t.setAttribute("data-clc-prefilled","true")}),m.forEach(function(t){t.id,googletag.cmd.push(function(){googletag.display(t.id)})}))}}},y.al&&h.push(function(){return clc.load()}),v()})()})();</script><script>
    var clc = clc || {};
    clc.collapse = { sb: !0, 'tag-sponsorship': !0, lb: !0, mlb: !0, smlb: !0, bmlb: !0, 'mobile-below-question': !0 };
    clc.options = clc.options || {};
    clc.options.sf = !0;
    clc.options.hb = !1;
    clc.options.ll = !0;
    clc.options.tlb_position = 0;
    clc.options.targeting_consent = !0;
    clc.options.performance_consent = !0;
        clc.cmd = clc.cmd || [];
        clc.cmd.push(function () { window.clc_request='A6ByPoqHENoIAAAAADXTDAACAAAAAgAAAAABFQAAAHxjfGZ1bmN0aW9uLXBvaW50ZXJzfAD_t2rXBw3AehgR'; clc.load(); });
        clc.dfp = clc.dfp || {};
        clc.dfp.targeting = {Registered:['false'],'so-tag':['c','function-pointers'],'tag-reportable':['c','function-pointers'],'tag-non-reportable':['c','function-pointers'],NumberOfAnswers:['11']};

        if (window.location.hash.indexOf('ads:cat=cp') >= 0)
        {
            clc.dfp.targeting.CompanyPageAd = '1';
        }
        
        clc.dfp.targeting.TargetingConsent = ['true'];

        const urlParams = new URLSearchParams(window.location.search);
        if (urlParams.has('dfptestads')) {
            const dfptestads = urlParams.get('dfptestads');
            clc.dfp.targeting.DfpTestAds = dfptestads;
        }
        
        var googletag = googletag || {};
        googletag.cmd = googletag.cmd || [];
        googletag.cmd.push(function () { clc.dfp.load(); });
        StackExchange.ready(function () { googletag.cmd.push(function () { StackExchange.ads.init(googletag, '/ads/report-ad', 'Report this ad') }) });
</script><script src="./How do function pointers in C work_ - Stack Overflow_files/clc.min.js"></script><script src="./How do function pointers in C work_ - Stack Overflow_files/gpt.js"></script>

            <footer id="footer" class="site-footer js-footer" role="contentinfo">
        <div class="site-footer--container">
                <div class="site-footer--logo">
                    
                    <a href="https://stackoverflow.com/"><svg aria-hidden="true" class="native svg-icon iconLogoGlyphMd" width="32" height="37" viewBox="0 0 32 37"><path d="M26 33v-9h4v13H0V24h4v9h22Z" fill="#BCBBBB"></path><path d="m21.5 0-2.7 2 9.9 13.3 2.7-2L21.5 0ZM26 18.4 13.3 7.8l2.1-2.5 12.7 10.6-2.1 2.5ZM9.1 15.2l15 7 1.4-3-15-7-1.4 3Zm14 10.79.68-2.95-16.1-3.35L7 23l16.1 2.99ZM23 30H7v-3h16v3Z" fill="#F48024"></path></svg></a>
                </div>
            <nav class="site-footer--nav">
                    <div class="site-footer--col">
                        <h5 class="-title"><a href="https://stackoverflow.com/" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 15})">Stack Overflow</a></h5>
                        <ul class="-list js-primary-footer-links">
                            <li><a href="https://stackoverflow.com/questions" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 16})">Questions</a></li>
                                <li><a href="https://stackoverflow.com/jobs" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 17})">Jobs</a></li>
                                <li><a href="https://stackoverflow.com/jobs/directory/developer-jobs" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 11})">Developer Jobs Directory</a></li>
                                <li><a href="https://stackoverflow.com/help" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 3 })">Help</a></li>
                        </ul>
                    </div>
                    <div class="site-footer--col">
                        <h5 class="-title"><a href="https://stackoverflow.com/?products" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 19 })">Products</a></h5>
                        <ul class="-list">
                            <li><a href="https://stackoverflow.co/teams" class="js-gps-track -link" data-ga="[&quot;teams traffic&quot;,&quot;footer - site nav&quot;,&quot;stackoverflow.com/teams&quot;,null,{&quot;dimension4&quot;:&quot;teams&quot;}]" data-gps-track="footer.click({ location: 2, link: 29 })">Teams</a></li>
                            <li><a href="https://stackoverflow.co/advertising" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 21 })">Advertising</a></li>
                            <li><a href="https://stackoverflow.co/collectives" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 40 })">Collectives</a></li>
                            <li><a href="https://stackoverflow.co/talent" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 20 })">Talent</a></li>
                        </ul>
                    </div>
                <div class="site-footer--col">
                    <h5 class="-title"><a class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">Company</a></h5>
                    <ul class="-list">
                            <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">About</a></li>
                        <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 27 })" href="https://stackoverflow.co/company/press">Press</a></li>
                            <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 9 })" href="https://stackoverflow.co/company/work-here">Work Here</a></li>
                        <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 7 })" href="https://stackoverflow.com/legal">Legal</a></li>
                        <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 8 })" href="https://stackoverflow.com/legal/privacy-policy">Privacy Policy</a></li>
                        <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 37 })" href="https://stackoverflow.com/legal/terms-of-service">Terms of Service</a></li>
                            <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 13 })" href="https://stackoverflow.co/company/contact">Contact Us</a></li>
                            <li class="" id="consent-footer-link"><a class="js-gps-track -link js-cookie-settings" data-gps-track="footer.click({ location: 2, link: 38 })" href="https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work#" data-consent-popup-loader="footer">Cookie Settings</a></li>
                        <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 39 })" href="https://stackoverflow.com/legal/cookie-policy">Cookie Policy</a></li>
                    </ul>
                </div>
                <div class="site-footer--col site-footer--categories-nav">
                    <div>
                        <h5 class="-title"><a href="https://stackexchange.com/" data-gps-track="footer.click({ location: 2, link: 30 })">Stack Exchange Network</a></h5>
                        <ul class="-list">
                            <li>
                                <a href="https://stackexchange.com/sites#technology" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Technology
                                </a>
                            </li>
                            <li>
                                <a href="https://stackexchange.com/sites#culturerecreation" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Culture &amp; recreation
                                </a>
                            </li>
                            <li>
                                <a href="https://stackexchange.com/sites#lifearts" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Life &amp; arts
                                </a>
                            </li>
                            <li>
                                <a href="https://stackexchange.com/sites#science" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Science
                                </a>
                            </li>
                            <li>
                                <a href="https://stackexchange.com/sites#professional" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Professional
                                </a>
                            </li>
                            <li>
                                <a href="https://stackexchange.com/sites#business" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Business
                                </a>
                            </li>

                            <li class="mt16 md:mt0">
                                <a href="https://api.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    API
                                </a>
                            </li>

                            <li>
                                <a href="https://data.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
                                    Data
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
            <div class="site-footer--copyright fs-fine md:mt24">
                <ul class="-list -social md:mb8">
                    <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link:4 })" href="https://stackoverflow.blog/?blb=1">Blog</a></li>
                    <li><a href="https://www.facebook.com/officialstackoverflow/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 31 })">Facebook</a></li>
                    <li><a href="https://twitter.com/stackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 32 })">Twitter</a></li>
                    <li><a href="https://linkedin.com/company/stack-overflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 33 })">LinkedIn</a></li>
                    <li><a href="https://www.instagram.com/thestackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 36 })">Instagram</a></li>
                </ul>

                <p class="md:mb0">
site design / logo © 2022 Stack Exchange Inc; user contributions licensed under <a href="https://stackoverflow.com/help/licensing">cc by-sa</a>.                    <span id="svnrev">rev&nbsp;2022.3.24.41762</span>
                </p>
            </div>
        </div>

    </footer>

    <noscript>
        <div id="noscript-warning">Stack Overflow works best with JavaScript enabled
            <img src="https://sb.scorecardresearch.com/p?c1=2&amp;c2=17440561&amp;cv=3.6.0&amp;cj=1" alt="">
        </div>
    </noscript>

        <script>
(function(i, s, o, g, r, a, m) {
                i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o),
                m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);
            })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

            StackExchange.ready(function () {

                StackExchange.ga.init({
                    autoLink: ["stackoverflow.blog","info.stackoverflowsolutions.com","stackoverflowsolutions.com"],
                    sendTitles: true,
                    tracker: window.ga,
                    trackingCodes: [
                        'UA-108242619-1'
                    ],
                        checkDimension: 'dimension42'
                });



                    StackExchange.ga.setDimension('dimension2', '|c|function-pointers|');


                    StackExchange.ga.setDimension('dimension3', 'Questions/Show');


                StackExchange.ga.setDimension('dimension7', "1648450355.926524633");

                StackExchange.ga.trackPageView();
            });
            
            var _comscore = _comscore || [];
            _comscore.push({ c1: "2", c2: "17440561" });
            (function() {
                var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
                s.src = "https://sb.scorecardresearch.com/cs/17440561/beacon.js";
                el.parentNode.insertBefore(s, el);
            })();
                </script><iframe src="./How do function pointers in C work_ - Stack Overflow_files/container.html" style="visibility: hidden; display: none;"></iframe>

        
    <div id="onetrust-consent-sdk" class="d-none"></div>
    <div id="onetrust-banner-sdk" data-controller="s-modal"></div>
    <div id="ot-pc-content" class="d-none"></div>
    <div id="onetrust-style" class="d-none">&nbsp;</div>
    <div class="d-none js-consent-banner-version" data-consent-banner-version="baseline"></div>

    
    
    
<iframe src="./How do function pointers in C work_ - Stack Overflow_files/aframe.html" width="0" height="0" style="display: none;"></iframe></body><style id="stylus-1" type="text/css" class="stylus">body {
    font-family: 'pragmata pro mono regular';
}</style></html>